.net – n equivalent to out-of-process COM EXE in .NET

activexcomnet

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?

Best Answer

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.

Related Topic