NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

CreateObject function (VB) and Active X reference initialization (Testand)

Hello,

I succeed in creating a new object reference from a VBA script by using the following function:
Set myObject = CreateObject("servername.typename")
It opens an application and gets an handle on it (stored into myObject)

But when trying to initialize an Active X reference on the same object within Testand I get in trouble...
- I am using an 'Action' step for ActiveX Automation adapter
- When specifying module:
- I select an ActiveX reference defined as locals
- I select "servername" as Automation Server
- I select "typename" as Object Class
- checkbox "Create Object" is set
- "Create new" option is selected in the following combo box

When running test, application is properly opened but then the following error message occures: "Create New Object" in automation failed. No such interface supported / Error Code: -17502; system Level Exception

It seems to me that Testand get in trouble to get the activeX reference after opening the slave application.

Does someone know the difference between VBA and Testand behavior to initialize an object reference ?
What could I do to succeed in initializing this ActiveX reference ?

Thank you for your help.
0 Kudos
Message 1 of 2
(3,804 Views)
Minimax -
ActiveX/COM objects have an apartment setting, either MTA(Multithreaded apartment) or STA(Single threaded apartment). MTA objects can be freely passed between threads. STA objects can only exist in a single thread. All of TestStand's objects are MTA, so TestStand execution threads are MTA. This speeds up performance. On the other hand, VB and VB script run in STA. For example an STA thread is required for dialogs that display an ActiveX control.

Depending on how the server is written, it will error, and if the error handling does not recognize this case, the error message might be unhelpful.

One option is to ensure that TestStand uses a thread that is initialized to STA. You can use a SequenceCall step to launch a new thread and in the thread settings, specify to make it an STA thread. If you need to, you can use a Wait step to wait for the sequence call to complete.

Hope this helps
Scott Richardson
https://testeract.com
Message 2 of 2
(3,802 Views)