有没有办法创建 C# 对象并从非托管 C++ 调用方法,但不使用 COM Iterop?我正在寻找类似 JNI(但适用于 .Net)的东西,您可以在其中手动创建 VM、创建对象等.
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,那么您可以直接与托管世界和非托管代码进行交互,因此互操作是微不足道的.
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 调用封装了很多功能.网上有很多信息,例如托管公共语言运行时".
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".
这篇关于在不使用 COM 的情况下从 C++ 调用 C# 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!