tags:

views:

231

answers:

1

Hi,

This question is a follow-up to the answer given by Marc Gravell to my question Create Out-Of-Process COM in C#/.Net ?. I have chosen his proposed solution, but now am running in a different issue.

Here is my situation:

  • I implemented a "DataProvider" COM component in C#
  • This component is hosted in a COM+ Server application so that multiple processes can access the same instance of the DataProvider
  • The types of processes that can access the data provider through COM are Matlab, VB Scripts and .Net applications.

When instantiating the COM DataProvider from Matlab or VB Script, the COM+ mechanism kicks in and I can verify that a single instance of the DataProvider can be used.

The problem comes when I try to access the COM+ managed instance from .Net. Basically, when a COM component is based on a .Net DLL, even with lazy loading, .Net always seems to find the DLL and instantiate the object from there, skipping the whole COM mechanism. This is expected for performances, but it does not help in my case.

Now for the question: Is it possible to instantiate a .Net written COM component in a .Net application using the COM mechanism?

Note that the following code does not use the COM mechanism:

 Type type = Type.GetTypeFromProgID(progID);
 return Activator.CreateInstance(type);
A: 

View this article :
Creating activex objects with c#
http://www.dreamincode.net/forums/showtopic38890.htm

lsalamon