LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Configure / interpret .NET variables declared as variant

Solved!
Go to solution

I have an application that is using a .NET dll which contains the following declaration and function call.  

daylateshort_0-1652826137123.png

Where variant is a declared as a public struct with 40+ overloads.

daylateshort_3-1652829843328.png

And VUInt64, as well as others, are defined as follows. 

daylateshort_4-1652829993741.png

 

In labview 2020 I have made the call as follows

daylateshort_2-1652829647157.png

 

Where result and the param# property nodes were created from the function call, (i.e. right click on result, param1, ... and select create Property for SDK.CSWrapper.Variant Class.) Then create control from that property noted. (Right click, create control).  LabVIEW seems happy enough with this but when it is run it errors these property nodes. Error 1172 [SDK.CSWrapper.Variant.VUnit64 (System.ArgumentNullException: Key cannot be null. Parameter name: key)].  I see that the value of result leading to the property node is 0000.  So presume that I did not either create the control properly though can see all the possible values (overloads) defined under the variant declaration when I access the property.  Hopefully just missing the obvious and the error is telling me but I'm not seeing it.

 

 

 

 

0 Kudos
Message 1 of 4
(752 Views)
Solution
Accepted by topic author daylate$short

You can't just use "Create control" to make an input for those, you need to create a constructor node.

 

"Create control" creates the correct type of wire, but that is all it does.  It doesn't put a value on it... you need to pass that in from somewhere else.  Hopefully you can create a constructor node of the types you need in LabVIEW.  If not, you might need to create a valid object in a custom .NET DLL, pass it to LabVIEW where it can then modify it, then pass it to the function in question you need to call.

Message 2 of 4
(727 Views)

Just to add to that, if you put a probe on one of those variants, you'll see the reference is 0.

 

Unless of course you use this VI as a subVI, and pass valid references to the controls as inputs...

 

Also, don't forget to close all those references.

0 Kudos
Message 3 of 4
(689 Views)

Thanks Kyle for your quick reply.  made the constructor from the top level Variant then the property node to select which type.  

0 Kudos
Message 4 of 4
(682 Views)