Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to out-of-process COM EXE in .NET?

Tags:

.net

com

activex

One of the nice things about COM/ActiveX was the out-of-process EXE. You could have an EXE which exposed methods and properties in a form usable by both other processes, including VBScript and JScript. At the same time the EXE could have its own functionality, related or unrelated to that exposed by its type library.

What is the .NET equivalent?

I have an existing VB6 project which is a scripting language interpreter (using MSScript) and a resource of various tool functions for other scripting languages. It has been suggested that I try converting it to .NET.

Is this going to work, or will I end up splitting the one item into two?

like image 420
bugmagnet Avatar asked Mar 03 '09 01:03

bugmagnet


2 Answers

Enterprise services will allow you to do just that. You can run a COM component as:

  • A DLLHost process
  • A service
  • An inproc library (this is in the same process as your other code)

There are numerous examples on the internet about these. What it comes down to is:

  • Decorate your classes that you need to expose to COM with Interfaces
  • Components that you want to host need to be derrived from ServicedComponent
  • Decorate your interfaces with a GuidAttribute (use a unique Guid)
  • Decorate the interfaces and classes that are exposed to COM with a ComVisible(true) attribute

Hope this helps.

like image 89
Jeroen Landheer Avatar answered Dec 18 '22 15:12

Jeroen Landheer


The .NET correspondence is .NET Remoting for .NET 2.0, and WCF for 3.0+. If you need to communicate with COM objects however, you must create a COM-exposed object instead. There are quite a few tutorials out there for that.

like image 36
ciscoheat Avatar answered Dec 18 '22 15:12

ciscoheat