04-01-2011 12:50 PM
I have a .NET DLL that has a method that takes as a by reference parameter an object of type NationalInstruments.TestStand.Interop.API.Execution. In TestStand 4.2.1 this worked fine if I passed it RunState.Execution.
Now in TestStand 2010 I get an error in TestStand that the method expected an object reference, but found an execution. An execution is what I want is what the method is describing. So, why does this not work?
Anyone have any ideas?
Thanks.
Solved! Go to Solution.
04-01-2011 01:20 PM
Do you get an error at runtime as well or does it just show an error at edit time?
04-01-2011 01:36 PM
Actually, there is no error at edit time.
I only get a runtime error.
04-01-2011 03:34 PM - edited 04-01-2011 03:39 PM
Hi Skeptical,
This is a known backwards compatibility issue introduced in TestStand 2010 and will be fixed in a future release.
That said, it doesn't really make sense for the parameter to be byref (i.e. in/out) in this case because the Execution interface is already a reference data type. Thus, passing it byref implies that the method has the possibility of replacing the object which RunState.Execution points to with a different Execution object which most likely is not something the method would ever do.
So as a workaround you can do one of the following:
1) Change the prototype of the method (or add a new overload) to take the execution parameter by value (i.e. in only), which is likely what the author of the code really intended anyway.
Or
2) Create a local variable of type Object Reference, and assign RunState.Execution to it before your call to the method, and then pass the local variable for the byref parameter.
Please let us know if you have any questions or if the workarounds are not sufficient for you.
Hope this helps,
-Doug
04-01-2011 03:51 PM
Thanks for your replies. I changed the parameter in my code to be by value rather than by reference and that solved the problem. In fact, as I looked further at the code, I don't know why I made it by reference in the first place. Thanks again.