Calling STA COM component from WCF.
Hi,
I have a VB STA com component and I use it as follows
public class Service1 : IService1
{
private ProjectSTA.ClassSTA x; ‘VB6 STA Component
public string GetData(int value)
{
Console.Write(Thread.CurrentThread.GetApartmentState().ToString()); 'return MTA
return x.GetName();
}
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
x = new ProjectSTA.ClassSTA();
}
Reading many articles I was expecting that it will fail since the service is run under MTA?!
I am using VS.NET 2010
Thanks in advance
Answers
- When WCF calls a com object it effectivey blocks all other calls to the WCF service until that com call completes, effectively becoming single threaded!
Even though WCF is MTA the MTA threads have to wait till the STA com call completes.One option is to expose COM+ component as a WCF service ,so we can use this option to communicate with COM+ component.
Please mark the response as answers if it solves your question or vote as helpful if you find it helpful. http://thoughtorientedarchitecture.blogspot.com/- Proposed As Answer byHaripraghash Sunday, November 08, 2009 1:10 AM
- Marked As Answer bytomer70 Sunday, November 08, 2009 7:26 AM
All Replies
Looks like the STA component is created in a different thread(the default thread created by com?)
Tomer
I think i understand....
.NET will correctly marshal calls from MTA to STA, the problem is that If several COM components is used by theService all calls to ALL components will be serialized through a single thread
So all parallelism is lost.
Can any one confirm this?
- When WCF calls a com object it effectivey blocks all other calls to the WCF service until that com call completes, effectively becoming single threaded!
Even though WCF is MTA the MTA threads have to wait till the STA com call completes.One option is to expose COM+ component as a WCF service ,so we can use this option to communicate with COM+ component.
Please mark the response as answers if it solves your question or vote as helpful if you find it helpful. http://thoughtorientedarchitecture.blogspot.com/- Proposed As Answer byHaripraghash Sunday, November 08, 2009 1:10 AM
- Marked As Answer bytomer70 Sunday, November 08, 2009 7:26 AM


