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

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

问题描述

有没有一种方法来创建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".

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

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