LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET dll integration; VI runs just once...

Hi all,

 

I'm trying to integrate a .NET dll into my Labview application. The project involves the interfacing of an USB instrument the manufacturer provided me the DLL and an C# example to work with. Currently I'm testing the developing on a XP with installed .NET framework version 4.0, Labview 2012 (demo version, since I'm going to upgrade my regular 8.0 license ASAP if this project works...)

I been able to replicate all the features proposed in the C# example, it requires some static (and not) .NET properties and methods calling but it works just the first execution. The second one the USB interface is not longer detected, with no error codes returned. At this stage I've two chances: physically disconnect and re-connect the USB cable or close and re-open Labview.

I've manage to close all references created by "non static" calls (the one I've REFNUM other than zero), anyhow "something" remains allocated in memory locking up the device. The C# example works correctly, so seems something Labview related (more likely my fault in programming...).

Is there a way to say to Labview: "Kill all exixting .NET references"?

Any other suggestion?

 

Many thanks in advance.

 

0 Kudos
Message 1 of 7
(3,330 Views)

I'm guessing you aren't releasing the device correctly. Is there a disconnect method available for the device? If so, call that before releasing the reference. I presume you've also taken the required steps to force LabVIEW to use .NET 4.0 instead of .NET 2? I would need to see code before I can be of further assistance (either C or LabVIEW is fine).

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 2 of 7
(3,324 Views)

Hi Charles,

 

Yes, I've done the required steps for .NET 4.0 use and yes, there is a "dispose" method (not used in the C# example) that doesn't make any difference if I use it or not. Monday I'll post the code I've it at work, now it's Friday evening here in Europe Smiley Happy

Many thanks for the fast response and the suggestions.

 

0 Kudos
Message 3 of 7
(3,313 Views)

Dispose is a fairly standard method and there is much debate over whether or not it should be called. I thought perhaps there was an actual disconnect hardware method like some hardware that I've seen. From what you have told me it would be most helpful to see both the C code and the LabVIEW code. If you do not wish to share the code publicly then I can send you my email via private message.

 

Charles

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 4 of 7
(3,307 Views)

Here the Labview code I've used to replicate the C# example. Since is just for testing I've not wired any error outs but I can assure you that no error is returned. Unfortunately no "disconnect" or similar method is available, only a generic "dispose" is present; I've tested it without any effect.

P.S. The DLLs aren't freeware, I cannot redistribute them.

 

code.jpg

 

Many thanks

0 Kudos
Message 5 of 7
(3,274 Views)

Do you ever close the references to the "Device"'s created in Steps 1, 2, and 3? That could be part of the problem. Also, you are creating three separate references there (unless this wiring is different from what you have shown), I would wire steps 1-3 together and close the reference when I finished with it.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 6 of 7
(3,260 Views)

Hi Charles,

 

The property / invoke nodes used in steps 1, 2 and 3 call static property / method so, from what I've understood, no instances are created and so I've no reference to close (I've checked that references returned are 0).

Does make any sense close a 0 reference? If not, this brings to my first question: Is there a way to say to Labview: "Kill all exixting .NET references"?

 

Many thanks again for supporting.

 

0 Kudos
Message 7 of 7
(3,251 Views)