从C ++调用C#方法而不使用COM [英] Call C# methods from C++ without using COM

查看:129
本文介绍了从C ++调用C#方法而不使用COM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法创建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,那么你可以直接与被管理的世界和非托管代码交互,所以interop是微不足道的。

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".

这篇关于从C ++调用C#方法而不使用COM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆