LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

cvi dll crash when exit (using with vc.net)

I created a dll project in CVI 7.1
Then I used the dll in my VC++.Net application. The calls to the dll functions is executed without any problem. But it crashed when I exitted the application.
 
If I removed all the dll function calls in the VC code, then the crash doesn't happen.
 
Please Help.
 
Thanks
0 Kudos
Message 1 of 9
(4,560 Views)
Hi, usvr.

Can you tell me a little about what your DLL is doing? I don't need to see your code -- just a general description of what's going on in there. Also, how is the crash occurring? (Does an error message appear? Does the program hang? Does your application just disappear?)
Sarah K.
Search PME
National Instruments
0 Kudos
Message 2 of 9
(4,545 Views)

Hi Sarah,

For the testing purpose, I only popup a message in the dll function (use MessagePopup). It doesn't crash at the time I call the dll function, but at the time I exit my Visual studio application.

 I can explain more details as follows:

+ This is the only dll function I used in the application.

+ The application crashed when exiting, not when the dll function is called. It always occurs, even the dll function is not called. This dll function is only call if I press a button on the visual studio application. If I just start the application and then I exit the application (without pressing the button to call the dll function), then the application also crashed when exitting. If I comment the dll function out, the application did not crash when exitting.

+ For testing purpose, the application doesn't do anything else. (only contains the button to call the dll function).
 
The crash occurs by popping up an error message (see attachment). And when I click ok on the popup message, the program disappears.
 
It only occurs in a C++.Net application (Windows Forms Application .NET). It doesn't occurs in the MFC application.
 
 
Thanks
0 Kudos
Message 3 of 9
(4,544 Views)
Hi, usvr.

I know you said your DLL only contains a call to MessagePopup(), but are you still passing data into or out of the DLL? This KnowledgeBase gives a good description of possible causes to this problem. (Though the KB refers to LabVIEW, the general principles could just as easily apply to a .NET application.) Let me know if some of these suggested fixes prevent the crash.
Sarah K.
Search PME
National Instruments
0 Kudos
Message 4 of 9
(4,516 Views)

The knowledge base you suggested doesn't apply to my case since I don't pass any data into the dll or get any data out from the dll.

As I said before, I created this dll is just to see if VC++.NET can call a CVI dll, so inside of the dll function, it only does one thing is popup a message "Hello".

It still crashed when exitting the application even the dll function was not invoked (I don't press the button to invoke the dll function).

0 Kudos
Message 5 of 9
(4,514 Views)
Hi, usvr.

In that case, I'm inclined to think that there's some sort of problem in either the DLL itself or the way its being called. Did you code your own COM interface for the DLL? If you're not sure what I mean by that, check out this post. Also, it may be helpful if you can attach a small exmple program demonstrating this crash.

Message Edited by sarahk on 03-10-2006 11:11 AM

Sarah K.
Search PME
National Instruments
0 Kudos
Message 6 of 9
(4,502 Views)

Hello Sarah,

I didn't create any COM interface. As I said before, it is a very simple dll just for testing. It contains only one dll export function, named Func1.

Attach are the MyDll project, which is the dll project I created with CVI 7.1, and the UseMyDll, created in VC++.NET, project which is using the dll.

 

Thank you.

Download All
0 Kudos
Message 7 of 9
(4,467 Views)
Hi, usvr.

Are you able to run other DLLs successfully from your code (either CVI or otherwise)? Also, is CVI installed on the same machine on which your VC++ code is being run? If not, what version of the CVI Run-Time Engine do you have installed on the target machine?
Sarah K.
Search PME
National Instruments
0 Kudos
Message 8 of 9
(4,454 Views)

I can run other DLLs, created by MFC, successfully. CVI 7.1 and Visual Studio.NET are installed on the same machine that I used to run the program.

 

Thanks

0 Kudos
Message 9 of 9
(4,443 Views)