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.
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.
07-22-2015 10:17 AM
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?
Solved! Go to Solution.
07-22-2015 10:31 AM - edited 07-22-2015 10:35 AM
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.
07-22-2015 10:56 AM
What is the instrument?
We might be working a very simillar issue
07-22-2015 11:06 AM - edited 07-22-2015 11:08 AM
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.
You should be able to close it then using the VISA Close function
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
Then LabVIEW does not have access to the com port and it can not close it.
07-22-2015 11:55 AM
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.