LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

cvixml and CoInitialize

Hello
 
I have a existing project. Now i want to add xml functionality.
I´m using the CVIXML library in my project. Since i use this library i have some problems in other parts.
Now i add CoInitialize() and CoUnInitialize() in my application and everything will work.
 
It is necessary to add these functions, if i use the cvixml library ?
I´m using CVI 7.1 and Windows XP.
 
Thanks Heiko
0 Kudos
Message 1 of 2
(3,244 Views)

The cvixml library is an ActiveX client of the Microsoft XML ActiveX server and uses the CVI ActiveX library in its implementation. All ActiveX code needs to be initialized using CoInitialize(Ex) - but this is automatically done for the cvixml library. The first call into the CVI ActiveX library will result in CoInitializeEx being called if required. If you have already called CoInitialize or the CVI equivalent CA_InitActiveXThreadStyleForCurrentThread, then this initialization will be skipped.

There are two ways to initialize ActiveX (COM) - MTA and STA. CoInitialize uses STA. CVI ActiveX library uses MTA by default. But some components (not XML) may require STA initialization and I think this is what is happening in your case. If you call cvixml, it initializes with MTA and then some other component in your program does not work. In this case, your solution of calling CoInitialize (or CA_InitActiveXThreadStyleForCurrentThread with STA) yourself is the correct one.

0 Kudos
Message 2 of 2
(3,239 Views)