From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

close .net assembly

Solved!
Go to solution

Hi all,

 

I have a quirky little bug I'm trying to chase down...

 

I have a USB instrument that I communicate with using a .NET assembly. I use a constructor node to create a reference to the .NET assembly, and invoke nodes to call the functions to communicate with my device. All of that works just fine.

 

My problem is when I try to close the reference to the .NET assembly. I am told by the supplier of the USB device (and .NET assembly) that the .NET assembly releases the COM port as part of the shut down process. When I use the Close Reference .vi on the .NET refnum, the COM port does not release until I exit labview. This leads me to believe the .NET assembly is still in memory and has not shut down, therefore it has not released the COM port.

 

Are my assumptions correct? Is there any other way to force the COM port to close through labview?

0 Kudos
Message 1 of 5
(3,773 Views)
Solution
Accepted by topic author sirwin

That is true. LabVIEW does not unload .Net assemblies once they are loaded. Your assemly should ideally provide a close method to release all its device resources rather than relying on the unloading of the assembly to free those resources.

 

The reason for this is among other things that unloading some buggy assemblies without terminating the calling process can crash the application pretty hard. Most assemblies are not specifically written with being dynamically unloaded and even less tested for that.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 5
(3,759 Views)

What is the instrument? 

 

We might be working a very simillar issueSmiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 5
(3,738 Views)

Are my assumptions correct? Is there any other way to force the COM port to close through labview?


Do you know what com port the .net uses and does it address it by Aliases  (COM) or by Canonical Name (ASRL1::INSTR)

 

On a VISA Ref drop down do you see something like this when the .net is running.

Com Open.pngYou should be able to close it then using the VISA Close function

Close Com Port.png

 

I suspect the the .net DLL has control of the comport and you will not be able to close it from LabVIEW

 

Or is it like this

Com Closed.pngThen LabVIEW does not have access to the com port and it can not close it.

 

 

 

Omar
0 Kudos
Message 4 of 5
(3,717 Views)

Thanks Rolf. That is exactly what I needed to know.

 

Jeff,

Without naming names, it is a tool to calibrate sensor ICs. The tool ships with a full-function GUI to access the registers and read the sensor output. The .NET assembly is included to allow scripting or implement a custom GUI with specific functionality. I'm working on the latter case.

0 Kudos
Message 5 of 5
(3,687 Views)