07-27-2012 10:41 AM
I have an interesting little puzzle....
I have an external device which is controlled through a .NET library. The interface VIs use property nodes and invoke nodes to use the underlying .NET objects. But, they present to normal programmer a set of normal VIs, so a normal programmer doesn't have to know OO LabVIEW.
This device needs initializing when the measurement system is turned on, which is rare and it hardly ever needs disconnecting. A user will generally use it for the length of a whole LabVIEW session. The predecessor of this device which used a .DLL written in C is often used that way. It appears that working this way isn't possible for the new device that uses .NET though. This is because the .NET objects to handle the device are destructed whenever the VI they are created in stops. That VI has to be stopped from time-to-time to make changes to code for example.
Has anyone found a solution to this problem?
07-27-2012 12:02 PM
Maybe I am not understanding your question, but LabVIEW has a separate .NET pallette for working with .NET assemblies.
07-27-2012 12:27 PM
It sounds like they have a set of wrapper VIs around a private assembly. If this is the case, then there's isn't a solution because technically, there isn't a problem. Each VI is like a miniature application. Hence, when a VI is stopped, references normally get closed. There are a few exceptions (like VISA resources), but .NET references aren't one of them. That's why if you have, for example, a .NET PictureBox on the front panel of a VI and you draw something in it, as soon as you stop the VI, the contents of the PictureBox go away. This is by design (and necessity).
The only thing you can do is to keep a VI running all the time so you can keep the reference "alive". This VI's sole purpose is to keep the reference in memory. (Make sure you put a small delay in the while loop so you don't hog the CPU.)
08-01-2012 10:07 AM
Thanks everyone. I've looked into this somemore and it seems there isn't a solution.