12-31-2013 05:52 AM
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
01-02-2014 12:46 PM
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.
01-04-2014 11:55 PM
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
01-06-2014 04:28 PM
Hi application_developper,
Thank you for informing me of this behavior, I am going to look into it.
01-13-2014 02:03 PM
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.
01-14-2014 12:03 AM
Thanks for the solution