07-18-2017 05:19 PM
Hello,
I am calling a .net dll driver. There is a variable defined as "System_Net_IPAddress IPAddr" in the .h file. I need to assign an IP address (e.g. 192.168.5.1) to the variable IPAddr. I am stuck how to do this.
I asked the .net dll author. He said IPAddress is a native type to .net. He uses
new IPAddress(new byte[] { 192, 168, 5, 1 }) or
IPAddress address = IPAddress.Parse(“192.168.5.1”) to do the assignment. But how to do this in CVI? Should I use CDotNetCreateArray and CDotNetSetArrayElements functions? Is there an example available?
Thanks a lot!
JZ
07-19-2017 08:10 AM
Hi jzhu0000,
LabWindows/CVI is strictly an ANSI C development environment. Is there a reason that you are using a .NET assembly with this IDE?
There is a way to call .NET assemblies from CVI. Follow this link to find examples:
http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/libref/cvidotnet_sample_code/
07-19-2017 08:54 AM
Hi mfaltin,
Thanks for your reply. The .net dll is a device driver that our main application written in LabWindows needs to call the device. No problem calling other functions in the .net dll package. Only this System_Net_IPAddress conversion. I will read the link more closely. But it doesn't look straightforward.
05-03-2023 04:41 AM
hello, please have you found a solution?
05-09-2023 12:46 PM - edited 05-09-2023 01:42 PM
Not sure about earlier versions but in LabWindows/CVI 2020 you have a .Net Instrument driver in samples\dotnet\SystemWrapper.fp
If you add that to your project you have 3 specific functions in there:
System_Net_IPAddress__Create()
System_Net_IPAddress__Create_1()
System_Net_IPAddress__Create_2()
You probably want to use the _2 variant, unless you need also IPv6 scopeID.
05-09-2023 01:52 PM
And if you want to create an IPAddress from a string, you would use the System_Net_IPAddress_Parse() function.