Ni.com is currently experiencing issues that may cause some pages to fail.

Support teams are actively working on the resolution.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Assembly Returns Null Reference

I have a .NET assemply from a customer that specifies a return value as a byte[].  I am assiging this value to an array of numbers, as is suggested by the .NET adapter.

 

In some cases the method returns a null object instead of an empty byte array, causing an error from the .NET adapter stating that is could not set the return value of the function since the reference does not point to an object.

 

Is there a way to get around this?  I could write a wrapper function to test for the null return, but I would prefer not to do that.

 

Mike

0 Kudos
Message 1 of 4
(3,344 Views)

Hi Mike,

 

I set up a test and found the same behavior.  Unfortunately the best way I can think of to get around this is the method you suggested, writing a small wrapper assembly to test for the null value and return an empty array or some unique array so you can handle it in TestStand.  If anyone else has any experience with this, I'd be interested to hear in how they got around this.

Eric B.
National Instruments
0 Kudos
Message 2 of 4
(3,317 Views)

I had the creator of the assembly make a change to not send back a null reference. 

 

I also found that I had a similar error if the array on the TestStand side was empty.  I set the array default to have one element and then the .NET assembly would resize the array, if required, even to an empty array. If I ran a second step when the previous step had  set the array to empty, it still worked.

 

This could have been the original problem.  Did your test case also use an empty array on the TestStand side?

 

Mike

0 Kudos
Message 3 of 4
(3,315 Views)

The TestStand 4.2.x Known Issues List contains the following known issue:

 

Error when passing an empty array to a .NET code module

Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 4 of 4
(3,297 Views)