NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

can not create an object for my c# form dll which has an ActiveX control

I want to create an object in teststand for my C# form dll which has an ActiveX Control . but the error says ActiveX control can not be instantiated because the current thread is not in a single-threaded apartment. can someone help to solve the problem?

 

Thanks.

0 Kudos
Message 1 of 5
(2,478 Views)

Two options:

 

1) put the step in a subsequence and use the sequence call "New thread" option with the advanced setting "Use single-threaded Apartment". Put a wait step immediately after the sequence call to wait for the new thread.

 

2) Inside of your dll, using .NET APIs create a new thread initialized as STA and call your code from that. Have the original thread wait for the new thread to finish running your dialog code.

 

Hope this helps,

-Doug

0 Kudos
Message 2 of 5
(2,441 Views)

Thanks for your help.

 

For the option(1),

 

i use the Action not the sequence call,  so how can i do that?

0 Kudos
Message 3 of 5
(2,439 Views)

You could create a new subsequence in your file, place the Action step in that sequence, and then call it from your main sequence with the Sequence Call step as Doug described. This allows you to use the STA option.

Daniel E.
TestStand Staff Product Support Engineer
National Instruments
CTA/CLD
0 Kudos
Message 4 of 5
(2,434 Views)

ok i solved the problem. Thanks a lot!

0 Kudos
Message 5 of 5
(2,429 Views)