02-22-2014 05:13 PM
I am trying to demonstrate how TestStand can retrieve data from a C# DLL method returning an array of type struct.
I created a custom type in TestStand that matched the signature .NET struct but I keep running into the same error:
"No corresponding subproperty in argument 'Locals.newarray<Array Element prototype>' of type 'Row' for field '<mystring>k_BackingField of .NET struct 'TestStandObjectArray.Row'."
I have set the ".NET Struct Passing" tab to "Allow Objects of this Type to be Passed as .NET Structs".
I have also tried "Exclude when Passing Struct" on this tab as well.
I have attached my DLL, CS file, TestStand sequence, and TestStand types.ini file.
Any tips or help would be appreciated.
Solved! Go to Solution.
02-23-2014 12:49 PM - edited 02-23-2014 12:50 PM
I think I see what the problem is. You made the members of Row properties rather than fields. Instead of:
public struct Row
{
public string mystring { get; set; }
public bool mybool { get; set; }
}
try this:
public struct Row
{
public string mystring;
public bool mybool;
}
The notation you are using "{ get; set; }", is a C# language shortcut for declaring a private field you don't care about accessing from code directly (that's why it gets named with k_BackingField) and a property to wrap it. TestStand struct passing only operates on fields, not properties.
Hope this helps,
-Doug
02-24-2014 08:16 AM
Thanks for the quick response Doug!
I'm not sure that I would have figured that out because we use properties almost exclusively for public members in C# classes!
Good catch, and the error makes perfect sense now!