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

我的梦境 提交于 2019-11-30 09:30:01
Jeroen Landheer

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.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!