Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

There are a few options for this; the most obvious being serviced components; this allows you to host the managed code in COM+ to run it in a separate process, but you need GAC/COM-callable etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top