LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX controls cannot be created in a thread whose concurrency model is multithread apartment %28MTA%29

Hello There

 

When i try to load panel with AxtiveX control (any type of activeX) from CVI i get the following error

(return value == -176 [0xffffff50]). ActiveX controls cannot be created in a thread whose concurrency model is multithread apartment (MTA)

 

Iam using CVI2013 sp1 on winXP

 

By the way i migrate the code from CVI 2012, on 2012 it worked perfectly

 

Thanks

Gabel Daniel

0 Kudos
Message 1 of 6
(5,534 Views)

hi application_developper,

 

This seems like it might be a bug, could you post a simple program that displays this error and I will look into it.

Peter T
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(5,477 Views)

Hi

 

The reproduction of the error is very simple.

 

Take the sample of UserInt\ActiveX\Webbrowser that is shipped with CVI,

add call to NiScope_Init() before loading the Main sample panel & walla the error is there.

It seems that call to Niscope changes the Thread behavior of  CVI

By the way i tried it with another call to IVI_SCOPE driver from Lecroy with the same result

 

Gabel Daniel

0 Kudos
Message 3 of 6
(5,403 Views)

Hi application_developper,

 

Thank you for informing me of this behavior, I am going to look into it.

Peter T
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(5,339 Views)

Hi applications_developper,

 

The fix to this issue is to call CA_InitActiveXThreadStyleForCurrentThread prior to calling NiScope_Init.  The explanation of this is that the ActiveX controls need to run with the apartment-threading-model (STA).  When the CVI run-time encounters an ActiveX control it will initialize the thread to STA.  What is happening is that NiScope_Init is probably initializing this to a multi-thread-apartment(MTA) first, so it is running into a conflict when the CVI run-time tries to run it on STA since its already initialized on MTA.

 

Let me know if that fixes the issue.

Peter T
Applications Engineer
National Instruments
0 Kudos
Message 5 of 6
(5,145 Views)

Thanks for the solution

0 Kudos
Message 6 of 6
(5,124 Views)