Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do I need to do to implement an "out of proc" COM server in C#?

Tags:

c#

interop

com

I am trying to implement an "out of proc" COM server written in C#. How do I do this?

I need the C# code to be "out of proc" from my main C++ application, because I cannot load the .NET runtime into my main process space

WHY?:
My C++ code is in a DLL that is loaded into many different customer EXE's, some of which use different versions of the .NET runtime. Since there can only be one runtime loaded into a single process, my best bet seems to be to put my C# code into another process.

like image 369
jm. Avatar asked Aug 27 '08 17:08

jm.


2 Answers

You can create COM+ components using System.EnterpriseServices.ServicedComponent. Consequently, you'll be able to create out-of-proc and in-proc (client) component activation as well as all COM+ benefits of pooling, remoting, run as a windows service etc.

like image 169
Erick Sgarbi Avatar answered Nov 17 '22 17:11

Erick Sgarbi


Here we can read that it is possible, but the exe will be loaded as an library and not started in it's own process like an exe. I don't know if that is a problem for you? It also contains some possible solutions if you do want to make it act like a real out of process com server. But maybe using another way of inter process communication is better. Like .Net Remoting.

like image 23
Lars Truijens Avatar answered Nov 17 '22 19:11

Lars Truijens