LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView 8.0.1 cannot return an enumerated value as a parameter from a .NET method

If I try to return an enumerated value as a parameter from a .NET method, I get the following error:
   "Object type cannot be converted to target type"

However, I am able to return an enumerated value as a function return from a .NET method. This problem does not occur in TestStand or C#.
 
Has anyone else encountered this problem?
0 Kudos
Message 1 of 5
(2,653 Views)
Can you post a small snippet of code that reproduces this, or at least a function declaration for a .NET method that would reproduce this situation in LabVIEW? Are you declaring your method as static? Does changing the method to non-static make any difference?
Jarrod S.
National Instruments
0 Kudos
Message 2 of 5
(2,642 Views)
See attached word document...
 
Thanks for your help!
0 Kudos
Message 3 of 5
(2,633 Views)
Okay, I've been able to reproduce the problem, and if you run it with the .NET 2.0 framework, rather than 1.1, you get a more detailed error message back from .NET:
 
Object of type 'System.Int32' cannot be converted to type 'LabViewNet.Enumeration&'. in LabView80.vi
 
So apparently the problem is in the data conversion routines we're using. I'll dig more into the problem to see if there is some sort of workaround
0 Kudos
Message 4 of 5
(2,621 Views)
I'm afraid there isn't a workaround in the 8.0.1 codebase. The bug is filed and is going to be fixed in the next release, but for now you have two choices...
 
1. If you want to use a byref signature, you'll need to define the signature to take an int and then convert the int to the enumeration inside the method.
 
2. Return the enumeration value as the retval of the method.
 
Personally I recommend #2, and in fact, you could change it to a full blown .NET property if you are only doing a simple get/set sequence.
Message 5 of 5
(2,610 Views)