使用C#DLL项目C ++ [英] using c# dll in project c++
问题描述
我想使用DLL在C#(Visual Studio 2008中)在C ++做项目(Visual Studio 2003中)。怎么做 ?请heeelp
有不仅仅是COM互操作多,在 <一个href=\"http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/adce905c-2bd3-4276-be53-c644dd928dfa\">MSDN常见问题解答 还列出了鲜为人知的方法:
2.2如何调用从本地的Visual C .NET程序集++?
有四种基本方法
从本地VC调用.NET程序集++
code。微软 有工作的例子全一体code框架
示范的方法。
本地VC ++模块调用 CLR托管的API 的托管CLR,负载和
调用.NET程序集。 (一体
code框架示例code:
CppHostCLR)
如果在.NET组件可以公开为COM组件,原生
VC ++模块可以调用到.NET
COM互操作 - 通过.NET程序集。
(全合一的code框架示例
code:CppCOMClient)
反向的PInvoke:托管code调用本地传递一个委托
本地code可以打电话回来。
(全合一的code框架示例
code:CSPInvokeDll)
如果含有天然VC ++ code模块允许使CLR ,本土VC ++ code可拨打
可直接通过它的.NET程序集
只是工程或IJW机制。 (全合一的code框架示例code:CppCLIWrapLib)
块引用>i want use dll made in c#(visual studio 2008) in c++ project(visual studio 2003). how to do that ? please heeelp
解决方案There is more than just COM interop, the MSDN FAQ also lists lesser known methods:
2.2 How do I call .NET assembly from native Visual C++?
There are basically four methods to call .NET assembly from native VC++ code. Microsoft All-In-One Code Framework has working examples that demonstrate the methods.
Native VC++ module calls CLR Hosting APIs to host CLR, load and call the .NET assembly. (All-In-One Code Framework Sample Code: CppHostCLR)
If the .NET assembly can be exposed as a COM component, native VC++ module can call into the .NET assembly through .NET – COM interop. (All-In-One Code Framework Sample Code: CppCOMClient)
Reverse PInvoke: the managed code call native passing a delegate the native code can call back. (All-In-One Code Framework Sample Code: CSPInvokeDll)
If the module containing native VC++ code is allowed to enable CLR, the native VC++ code can call .NET assembly directly through the "It Just Works", or "IJW", mechanism. (All-In-One Code Framework Sample Code: CppCLIWrapLib)
这篇关于使用C#DLL项目C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!