调用C#从C ++方法不使用COM方法、COM

由网友(前行)分享简介:有没有一种方法来创建C#对象和调用方法从非托管C ++,但不使用COM Iterop?我在寻找类似JNI(但对于.NET),在那里你可以手动创建虚拟机,创建对象,等等。Is there a way to create C# objects and call methods from unmanaged C++, bu...

有没有一种方法来创建C#对象和调用方法从非托管C ++,但不使用COM Iterop?我在寻找类似JNI(但对于.NET),在那里你可以手动创建虚拟机,创建对象,等等。

Is there a way to create C# objects and call methods from unmanaged C++, but without using COM Iterop? I am looking for something like JNI (but for .Net), where you can manually create the VM, create objects, etc.

推荐答案

如果您使用的是C ++ / CLI,那么你可以与被管理的世界和非托管code直接交互,所以互操作实在是微不足道。

If you are using C++/CLI then you can interact directly with both the managed world and unmanaged code, so interop is trivial.

您也可以托管CLR自己,而托管API是基于COM,你可以再创建任何托管对象。这个过程是不是一个困难的,因为它听起来那么几个API调用封装了很多功能。有很多的信息网上,例如在 MSDN文档托管的公共语言运行时。

You can also host the CLR yourself, and whilst the hosting API is COM based, you can then create any managed object. The process isn't a difficult as it sounds as a few API calls encapsulate a lot of functionality. There is a lot of info online, for example the MSDN documentation on "Hosting the Common Language Runtime".

阅读全文

相关推荐

最新文章