Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Working with DCOM in Measurement Studio for VC++ environment

I have Measurement Studio for visual studio.NET - version 8.I have an existing project that did'nt include NI support,i added Measurement Studio Class libraries,but when i run the application the dialog that includes the NI controls throw an assert in the function that creates the OLE controls the reason for this is that when my application is starting before i create the dialog that includes the NI controls i call the CoInitializeEX function - i am using  DCOM in my application.What can i do to be able to work with the DCOM + NI support?
0 Kudos
Message 1 of 4
(5,793 Views)
Hi adi b,

Which NI controls are you using on your dialog?
If you are using the ActiveX controls, why not use the .NET controls since you are in the .NET programming environment and they have more functionality?
Regardless, if you create a new project and use the controls, do you see the same error?

Regards,
0 Kudos
Message 2 of 4
(5,770 Views)

Hi,

I am using CNiGraph,CNiKnob controls.

If i start a new project i have no problem to work with these controls.

The problem is, that i have an existing project, i added the NI classes to this project

When my project is starting i am calling the CoiIntializeEX(NULL,COINIT_MULTITHREADED) function --> i am using MTA threading model.

When the dialog with the CNiGraph,CNiKnob controls is created OLE assert is produced.

I tried replacing the call to the CoiIntializeEX(NULL,COINIT_MULTITHREADED) when the application start to this: CoiIntializeEX(NULL,COINIT_APARTMENTTHREADED)

using the using STA threading model and when i load the dialog with the CNiGraph,CNiKnob controls there was no assert and all was OK.

But i can't use the STA threading model because i have several threads in my project that should use the DCOM and it could not be done if i use the

COINIT_APARTMENTTHREADED in the CoiIntializeEX function.

So how can i solve the problem of working with OLE controls in DCOM environment with MTA threading model???

0 Kudos
Message 3 of 4
(5,766 Views)
Hi adi b,

Unfortunately, most ActiveX/COM objects including the NI Active X controls like CniGraph and CNiKnob, are configured to work in STA mode only. As a result, your application must conform to this model as you have already proven by using CoInitializeEX(NULL,COINIT_APARTMENTTHREADED).

Regards,
0 Kudos
Message 4 of 4
(5,745 Views)