NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Object Reference

Solved!
Go to solution
Hi : I am new to object oriented and .NET programming. To access a property in a .dll, I created an object reference to the property, but I got an error : The object specified in the class reference is not a .NET object. Since you are not creating a object, this must be a .NET object I went through NI's description below, but I am more confused. I can probably copy and paste from some other working code and get what I am trying to do to work. However, I want to understand objects, object references, classes, properties and methods as pertaining to how NI handles them in providing access to .NET modules. Where can I begin? Please help. Object Reference—A variable or property of type object reference. When a step creates an object, the .NET Adapter assigns the reference to the variable or property, if specified. Otherwise, the .NET Adapter automatically releases the reference after executing the step. If the step does not create an object, but instead calls a non-static method or accesses a property, this control must contain the value of a valid object reference that refers to the object on which to call the method or access the property. For static methods and properties, the .NET Adapter ignores this control. Click the Expression Browse button to launch the Expression Browser dialog box. Click Create Type from Struct to create a named data type that contains properties for each element in the struct selected in the Class control. If the step operates on a struct instead of an object, you can specify a variable or property of type object reference, or a named data type that contains properties for each element in the struct selected in the Class control. If you specify a named data type and the step creates the struct, the .NET Adapter calls a constructor for the struct to initialize its elements. If you specify a named data type and the step does not create the struct, the .NET Adapter automatically creates a temporary struct and assigns the values in the TestStand named data type to the struct elements. After executing the step, the .NET Adapter assigns the struct element values back to the TestStand named data type. Note When TestStand releases a .NET object, the .NET Common Language Runtime (CLR) makes the object available for garbage collection, so the object might not be disposed of immediately. If the object implements the IDisposable interface, use the Call Dispose on Release of Object option on the Configure Class Constructor window to immediately garbage collect the object. Class—The name of the class on which the step operates. When you select an assembly, the .NET Adapter populates this control with a list of classes defined for the assembly. Create Object—Specifies whether the step creates a new object, and whether to operate on the object locally or on a remote system. When you enable the Create Object option, you can click Customize Constructor to launch the Configure Class Constructor floating pane, in which you can select the constructor method to invoke and specify the parameters when creating an object or initializing a struct
0 Kudos
Message 1 of 5
(4,095 Views)
Solution
Accepted by kerugoya

Hi Kerugoya,

 

I’ve got a few links for you that may help.

Visual Studio Object Oriented Programming - http://msdn.microsoft.com/en-us/library/dd460654.aspx

Here’s a link to Object Oriented Programming in C#: (http://zone.ni.com/devzone/cda/ph/p/id/7).

Might be helpful to take a look at the .NET Class Hierarchy Chart - http://digital.ni.com/manuals.nsf/websearch/2D5660F0060CF256862577AB007FF67E

 

Regards,

 

Michael Miracle

NI Americas | AE

0 Kudos
Message 2 of 5
(4,071 Views)

Hi Kerugoya,

 

Also, you should probably post your questions here if it's .NET related : http://forums.ni.com/t5/Measurement-Studio-for-NET/bd-p/232

 

Regards,

 

Michael Miracle

NI Americas | AE

 

0 Kudos
Message 3 of 5
(4,068 Views)

Thanks for this information.  I have to deliver something for work in a short while, so I would greatly appreciate if you may please help to clarify the questions below for me.  I plan to read up on everything else you have mentioned later.  Here are my questions :

1.  If the "Create an Object" tick mark is grayed out for a property, what does that mean?

2.  Can I simply create a local object reference type variable to access a property and retrieve the information I need from the property?

0 Kudos
Message 4 of 5
(4,063 Views)

Hi Kerugoya,

 

Can you re-post your question in the Measurement Studio Forum I mentioned above. I think you'll get more support there.

 

Also, when you do, post a screen shot for question 1, I think it will depend on the property whether you're able to create an object. Once you have an object created you should be able to get the property as long as it's a public property. If it's private, there will probably be a get or set method to access it. If you can list some of the properties/objects that you're dealing with and what you're using to access them, that would be helpful for the post.

 

Regards,

 

Michael Miracle

NI Americas | AE

 

 

0 Kudos
Message 5 of 5
(4,059 Views)