.NET Core 2.1 - How to create COM object and generate *.tlb file

强颜欢笑 提交于 2019-12-05 10:51:28

This is now possible due to the work done on .NETCore version 3. As noted in my comment, hosting was the missing piece in earlier .NETCore versions with no substitute for mscoree.dll. Version 3 provides comhost.dll. Related, they also can now support C++/CLI code, ijwhost.dll is the substitute.

You register the component like you did with traditional COM servers, using Regsvr32.dll

Everything you need to know is available in this MSDN page, added a month ago. Do beware that .NETCore 3 is still preview quality right now. And this is Windows-only with no migration path for Linux and macOS, COM is too heavily tied to services that are only available on Windows.

As an alternative to COM, you could host the .NET Core runtime in your native process to call managed code.

Hosting the .NET Core runtime is an advanced scenario and, in most cases, .NET Core developers don't need to worry about hosting because .NET Core build processes provide a default host to run .NET Core applications. In some specialized circumstances, though, it can be useful to explicitly host the .NET Core runtime, either as a means of invoking managed code in a native process or in order to gain more control over how the runtime works.

Links:

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