问题描述
有没有办法创建 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# 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)