11-04-2010 08:08 AM
i have created a small dll, which holds 1 exported function.
The dll is created in VisualStudio2008, sp1
With option /CLR, targetting .NET framework 2.0
The export is like below:
***********************************************************************
extern "C" int __declspec(dllexport) __stdcall testHelloWorld(void)
{
System::Console::WriteLine("Hello world") ;
System::Console::WriteLine("Hit the any key") ;
System::Console::ReadKey() ;
return 0 ;
}
***********************************************************************
The following code should run this dll, from cvi 9.0.1 (375)
***********************************************************************
extern int __stdcall testHelloWorld(void) ;
typedef int (__stdcall * HelloWorldPtr) (void) ;
void main(void)
{ HMODULE hLib = 0 ;
HelloWorldPtr doit ;
SetStdioPort (HOST_SYSTEM_STDIO);
SetStdioWindowVisibility (1);
hLib = LoadLibrary("CppTestClr.DLL") ;
(FARPROC)doit = GetProcAddress(hLib,"_testHelloWorld@0");
doit() ;
// testHelloWorld();
}
***********************************************************************
When i run the dll with run time linkage (as show above) there is no error, all ok.
When i try to run the dll with load time linkage (line 'testHelloWordld' linked-in ),
cvi shows an error 'A non-debuggable thread caused a general protection fault at address...'.
This message is shown before the main function is reached.
Visual studio has no problem in running the code from a win32 console application.
Labview runs the code without problems.
Why won't cvi load the dll ??
tnx.
11-04-2010 08:58 AM
Hello -
This is a known issue in LabWindows/CVI 2009 SP1 and earlier. Currently the only workaround is to dynamically load the library. A solution for this issue will be available in the next major release of LabWindows/CVI.
NickB
National Instruments
11-04-2010 09:11 AM
Thanks for (very) fast response.
If my information is corrrect, the next Major release is CVI 2010.
So i hope it will be solved in this version.
Grtz.
@nickb wrote:
Hello -
This is a known issue in LabWindows/CVI 2009 SP1 and earlier. Currently the only workaround is to dynamically load the library. A solution for this issue will be available in the next major release of LabWindows/CVI.
NickB
National Instruments
11-04-2010 09:25 AM
A solution will be available, but due to the complexity of this issue LabWindows/CVI 2010 will not work for you out of the box - a configuration will have to be made. I've made a note to come back and update this post when LabWindows/CVI 2010 releases with instructions concerning this configuration.
NickB
National Instruments
11-04-2010 09:46 AM
@nickb wrote:
A solution will be available, but due to the complexity of this issue LabWindows/CVI 2010 will not work for you out of the box - a configuration will have to be made. I've made a note to come back and update this post when LabWindows/CVI 2010 releases with instructions concerning this configuration.
NickB
National Instruments
I'm an SSP member, so i'll receive the new version automatically.
Maybe it's a good idea to also create an entry in the release notes of version 2010.
These are my first attempts in using c++ dll's as a .NET wrapper for cvi.
But it looks very promising. Comparing to the .NET wrappers in cvi it's much more convenient (native way of working).
I would like to be able to use this as a generic way of working.
12-07-2010 10:10 AM
Hello -
Now that LabWindows/CVI 2010 is available, you can read here for information on how to configure LabWindows/CVI 2010 to load mixed-mode DLLs correctly. Let me know if you have any questions, or if this does not resolve your crashes.
NickB
National Instruments