Call C# methods from C++ without using COM(在不使用 COM 的情况下从 C++ 调用 C# 方法)
问题描述
有没有办法创建 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# 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在不使用 COM 的情况下从 C++ 调用 C# 方法


- 使用 rss + c# 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01