NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Expected object reference found execution

Solved!
Go to solution

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.

0 Kudos
Message 1 of 5
(3,819 Views)

Do you get an error at runtime as well or does it just show an error at edit time?

0 Kudos
Message 2 of 5
(3,816 Views)

Actually, there is no error at edit time.

 

I only get a runtime error.

0 Kudos
Message 3 of 5
(3,811 Views)
Solution
Accepted by topic author Skeptical

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

Message 4 of 5
(3,803 Views)

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.

0 Kudos
Message 5 of 5
(3,794 Views)