12-20-2023 08:52 AM
Hi there,
here I am again with a very strange question:
I have a local variable of Type Object Reference. During Runtime, the Variables Pane shows the type of .net reference stored in this variable:
How can I access this information using the TestStand API? I have tried to use the PropertyObject API but failed so far with TestStand telling me more or less the same
Can anyone nudge me in the right direction please?
Cheers
Oli
Solved! Go to Solution.
12-20-2023 03:50 PM
A .NET class object can be anything, so TestStand has no way to process it. The best you can do is hold a reference to it and pass it to another .NET class.
TestStand can only pass, standard data types: Number, String, and Boolean and References to objects
Or create TestStand type container and mark that Type to be allowed to pass C# struct and pass a reference to the C# class. Then populate the fields of the struct, then the data will show up in TestStand.
12-21-2023 12:22 AM
Understood!
In my use case, I need to check if a Object Reference Type variable holds a certain .net class type (DateTime in this case). Since the Variables Pane of the Sequence Editor seems to be able to determine this, I suppose there must some way to achieve this progamatically in TestStand
12-21-2023 05:07 AM
After talking to a colleague who's very much into .net my interpretation is that the Variables Pane Control uses some .net functionality
For future reference:
Throws error on NULL references, but also seems to work with COM references (like ActiveX objects)
12-21-2023 10:35 AM - edited 12-21-2023 10:38 AM
How can I access this information using the TestStand API?
Your original question was how to access an arbitary object via "TestStand API", so I approached the answer only in that context. (Answer is: you cannot. TestStand PropertObject API can only access TestStand objects). And as I replied before and you found out, access of .NET object is possible only using additional .NET assemblies until you get to a return value of basic data types (String, Number, Boolean), which at that point TestStand can consume the value into a variable.
This holds true for any Class Object architecture (C, C++, C#, etc).
12-22-2023 01:00 AM - edited 12-22-2023 01:00 AM
Sorry, for the wording, no intention to upset you
12-28-2023 08:01 AM
@Oli_Wachno wrote:
Understood!
In my use case, I need to check if a Object Reference Type variable holds a certain .net class type (DateTime in this case). Since the Variables Pane of the Sequence Editor seems to be able to determine this, I suppose there must some way to achieve this progamatically in TestStand
Many years ago I created a suggestion that never materialized. Still amazed that more people don't run into problems with this.