Question : Interop COM and WCF

Hi,

I need some advice with regard to using WCF to service a COM object from a legacy ERP system we use.

We're in the process of developing key WCF classes to handle calls to the ERP's COM libraries.  The core component of this apparently runs in an STA model (as I understand all COM objects do).

I'm just trying to understand the implications of calling this across multiple WCF instances.  For example, say I've got an order WCF class to pop an order into the ERP.  If this class was called 10 times with 10 different orders, then I think 10 instances of the ERP would be created (via the API) and the orders should go in?

Would I be correct in saying that as they are operating in their own STA, there's no reason this can't work - as none of the other threads running will be able to interfere with one another?  The InprocServer32 value for the library/exe of the ERP is set to Apartment so I know they're definitely operating in a non-MTA manner.

I did a quick test which calls the API and logs into the ERP wrapped in a WCF class.  Running the WCF class in session mode allowed me to login almost simultaneously with no problems, and to prove it I then ran the class in Singleton mode and it went in one after the other as expected.

I think I just need confirmation of any possible pitfalls taking this approach may have.

Cheers,
Tony

Answer : Interop COM and WCF

Yes when there are 10 diferent orders then , there would be 10 instances of ERP would be created.

Yes threads will not interfer with other threads running.

You are also right with Session mode and singleton mode.  

Call WCF in session mode and let the calls be Async.
Random Solutions  
 
programming4us programming4us