LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

using LabVIEW dll in C#

Is it possible to work with such a datatype in C#? For example, I need to establish a VISA connection, but I am unsure how to pass my IP address to the method since the IP address is a string, but the method requires a pointer. Does anyone have an idea on how to solve this?

 

I've also included my attempted solution in the images below.

Thank you in advance!image.pngimage.png

0 Kudos
Message 1 of 4
(636 Views)

Unfortunately your VISA Resource is in C terms actually a so called VISA Session handle and not directly compatible with a string form. The LabVIEW VISA Session Control is a convenience control that associates a sessions name to the underlaying VISA Session Handle.

 

What you need to do is to change the according parameter to a string control and then rebuild your DLL. Make sure that the Control is being configured as a C String Pointer in the DLL interface configuration of your DLL build specification.

 

Then you can pass a C String pointer from your C# program. But this must be a Zero Terminated ASCII string, not IntPtr to a C# string (which would be a UTF-16 string).

 

Alternatively you could also choose to build a .Net Assembly from LabVIEW code, instead of a classical DLL. This would make several things easier as you do not need to do your own Interop marshalling to call that assembly. You still need to make the VISA resource a string though, C# doesn't have a VISA Session Control equivalent, this is really a special LabVIEW convenience feature.

Rolf Kalbermatter
My Blog
Message 2 of 4
(611 Views)

Or you can just program NI-VISA in C#.

NI-VISA .NET Library

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 3 of 4
(583 Views)

Thanks for the answer. I will do my best to bring it work 

0 Kudos
Message 4 of 4
(536 Views)