LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do we unload a DLL with multiple different CLFN?

Solved!
Go to solution

@Abel_ge wrote:

Hey folks.... Greetings...

 

I was having a look at this tread as i was trying something similar. I have a similar piece of code which uses a valid path or the "Not a Path" constant to load / unload the dll in one vi. However once the dll is loaded using a valid path, i have calls to numerous dll functions in multiple different vi's. Once the data has been acquired from the dll, i invoke the initial vi and pass in the "not a path" constant so that the dll gets unloaded (Hopefully).

 

Would this unload the dll correctly?

 

Also Mathieu, u said you did a lot of tests to confirm if the loading / unloading was successful. Could you please let me know how u tested this. I am using Labview 2012 on an XP system.

 

I am facing the issue of static variables in the dll not being destroyed and recreated when the next session of data acquision starts. (Sessions are started & terminated by the user pressing Start & Stop buttons on the UI).


That can't work! Each CLN maintains a link to the DLL and only unloads the DLL when the VI itself is unloaded from memory or the path changes. As long as there is one single CLN referencing your DLL and its path has not been reset to a different path, the DLL will remain in memory.

 

Basically any DLL relying on it to be unloaded/reloaded to work properly should be considered totally broken. And storing data created in one function in a static variable to be retrieved by a different function is a very bad design pattern. Why not let the initial function directly return the data?

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 11 of 13
(707 Views)

Hey Rolf, Many Thanks for the inputs....

 

Yes i should look into the dll for clearing of data variables as i have Start & Stop session  methods that are being invoked from Labview. I think that would be the real fix rather than loading/unloading the dll through Labview 🙂

 

Best regards, Abel.

0 Kudos
Message 12 of 13
(699 Views)

Hi Abel,

 

In my code, my DLL, was accessing some internal data saved by other functions.Since I couldn't only run my function and return the results due to high complexity of the code, I had to store some values in Variables, and I was simply reding them when I needed to know the output. So basically, I was only checking if the output of my function was changing since I had access to this value.

 

However, as rolf said, that not a good design, but in my situation, I had no other choice and it was one the the first project I was working on in LV.

 

Best Regards,

Mathieu Veillette, Ing Jr.
0 Kudos
Message 13 of 13
(693 Views)