I'm running CVI 2010 (10.0.1.419) and TestStand 2010 SP1 f1(220.127.116.11).
I ran into an issue today and I know I must be missing something easy. I'm trying to create a step type with an Edit Substep. The Edit Substep called a CVI function as its code module. The CVI function opened a panel containing an ActiveX control.
When I try to use the edit substep (clicking on the button in an instance of the step type), I got an error that the DLL cannot be loaded. Changing the CVI adapter setting to Execute Steps in an External Instance of CVI let me see that CVI is getting a NON-FATAL RUN-TIME ERROR that "ActiveX controls cannot be created in a thread whose concurrency model is multithread apartment (MTA)".
I know that Edit substeps are supposed to use STA threads (there's a post from Doug somewhere around here...ah, Here it is). So I wasn't sure what was going wrong. I created the simplest example I could think of with nothing but a IE WebBrowser control on a panel in a .uir and still got the same error.
Even stranger was that I got the error when running one of the TestStand examples! I tried the \Examples\StepTypes\CVI\HP34401a example and got the same error:
NON-FATAL RUN-TIME ERROR: "c:\...\StepTypes\CVI\HP34401a\HP34401aStepType.c", line 356, col 5, thread id 0x00001694: Library function error (return value == -176 [0xffffff50]). ActiveX controls cannot be created in a thread whose concurrency model is multithread apartment (MTA)
There must be something I'm doing wrong, or some option that is set incorrectly. Any ideas?
Solved! Go to Solution.
Edit substeps are run in an STA thread if executed in process. If you execute in an external CVI then you will get an MTA thread. You probably don't want to generally be running edit substeps in an external CVI though, that is why there is an "Always run in process" checkbox on the CVI module specification panel (I recommend all step type developers using CVI modules for substeps use this setting for all of their substeps). Your original issue was likely unrelated to the COM threading model. I recommend you debug by debugging the seqedit.exe process with CVI rather than running your modules in an external CVI.
Hope this helps,
So there was an option I was setting incorrectly. That's exactly what I needed to know. When I changed the adapter back to in-process, the TestStand example worked (the step type should probably ship with the 'always run in process' option checked though).
I'll now go double-check all my steps that use CVI modules for substeps to make sure that option is checked.
And you're right, my original issue seems not to be related to the COM threading model, because I'm still getting the error. I may have more questions on it, but I'll create a new thread if I can't figure it out myself.
I agree, the example should have the setting set. I will record that as something to fix in a future version.