LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issue using DLL / library function node

Hi All
I am using labview 8.2 / 8.0
I am writing a wrapper DLL to convert compex data types of a DLL to simpler ones for labview intefacing.
I have read the forums on all related items and could not find a solution.
I have cut my code back to basics and I am still getting error 1097 with 8.2 and a crash with 8.0

The error occurs as follows:
1) Start labview, open the vi.
2) Run vi - everything works (so far the wrapper DLL I am writing call just does a simple open handle and close handle on a driver dll).
The handle is passed back to the vi, and everything is good.
I can re-run the application numerous times and it always works

3) IF I close the vi, but not labview and re-open I get the following:
Labview 8.0 crashes on closing the vi
Labview 8.2 does not crash, but I get error 1097 if I re-open and run the vi.

So it seems like it's almost working but the issue comes on the release of the dll from one invocation of the vi to another.

I don't know what the error is, but I've tried everything I can think of! Any suggestions would be appreciated!

Note: I am not passing any arrays at the moment, but I am passing one unsigned 32 bit int pointer. I declare a constant for this in the call, so there is something for the pointer to use, and it seems to return the data ok.

0 Kudos
Message 1 of 4
(2,903 Views)
When you load a DLL in LabView it is loaded for the whole LabView, not only for your VI.
This might be causing the problem.

First of all, does the driver work on its own? From another programming language that does not
need a wrapper? If so, then we can isolate the problem to be either in the wrapper or in LabView code.
Most propably the wrapper thought Smiley Happy

I assume you have written the wrapper with C or C++, so make sure you don't have any memory leaks
or null pointers in the code.

Are you sure you want to use const pointer?

The C++ 'const' Declaration: Why & How


0 Kudos
Message 2 of 4
(2,886 Views)
Hi Kaem,
Thanks for your reply.
I have written C++ standalone programs that link to the DLL and these work fine. I have even called my wrapper DLL from a C++ program and that too works fine (just to check if the wrapper would cause issues there). I have a hunch that it is actually the DLL that my wrapper is 'wrapping' that is causing the issue, but I guess I don't know for sure.
The difference (IMHO) is that these C++ programs all run through once and then exit, so everything works fine. However if they load the DLL and unload it and try to load it again, maybe there would be an issue. I think labview is doing this.

The reason I think labview does something funny with the DLL after you exit a VI (but not labview) is because labview crashes in 8.0 when the VI is closed (8.2 is ok, but the next DLL invocation fails when the VI is reopened), so something must be happening at this point - and I think it's an ungraceful unload of the DLL.
Also, I've noticed that I cannot overwrite my wrapper DLL with a new version until I exit a VI - so labview is definitely doing something on VI close - it's releasing some lock on the DLL.

I don't use any consts in my code  - sorry if I indicated that. What I have is a U32 constant in labview, and I connect that to the input of  the library function node, and pass it as a pointer. And the DLL writes into this then. Are you saying that a labview constant cannot be used as an input to a function and passed as a pointer ? What should I use instead, a control?
Note: while writing - I just tried that - same error -  so I don't think this is it.

I'm willing to take any and all suggestions!!

Cheers
John

0 Kudos
Message 3 of 4
(2,877 Views)
Loading, unloading, and then loading a DLL should not cause the error you're seeing unless you're doing something funky with memory in your DLL attach and unattach procedures. Wiring a constant to an input that's passed as a pointer is perfectly fine. I've done it many times. Can post some code? Like, perhaps, the header file for your DLL, or even better the DLL with the VI(s)?
0 Kudos
Message 4 of 4
(2,863 Views)