05-31-2013 11:08 AM
I am reading from a device through a .NET DLL. The read gives me a variant, and its type is reference number. I believe I am getting a reference number for a .NET object, and I need to get to its property to get its real value. How do I do that?
06-03-2013 04:29 PM
Hi jyang72211,
Are you trying to use .NET property nodes? Example: Converting your .NET reference (of variant data) to some other type of data (by using the variant to data.vi) and then wiring the reference in to a property node?
Thanks,
06-04-2013 06:37 AM
@jyang72211 wrote:
I am reading from a device through a .NET DLL. The read gives me a variant, and its type is reference number. I believe I am getting a reference number for a .NET object,[...]
Variant is a common type for API functions in .NET and ActiveX. LV has functions to convert any data type into a variant ("to variant") and to extract any data type from the variant ("from variant"/"Variant to Data").
Putting data to variant is easy, but when extracting, you need to know which type you expect in the variant. Therefore, you have to connect a prototype of the data type to the "Variant to Data" function.
If the data is numeric, you have to connect an appropriate numeric constant (e.g. U16) to it.
If it is a handle to a .NET object, you have to create a constant for such a reference. You can do this by several different approaches. But all of them have in common that you have to know (and browse for) the exact object type of the .NET object "behind" this reference.
One way for instance is to create a reference control on the front panel, browse for the .NET object type and then change this control to be a constant.
hope this helps,
Norbert