使用C#DLL项目C ++ [英] using c# dll in project c++

查看:151
本文介绍了使用C#DLL项目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框架
  示范的方法。


  
  

      
  1. 本地VC ++模块调用 CLR托管的API 的托管CLR,负载和
      调用.NET程序集。 (一体
      code框架示例code:
      CppHostCLR)


  2.   
  3. 如果在.NET组件可以公开为COM组件,原生
      VC ++模块可以调用到.NET
      COM互操作 - 通过.NET程序集。
      (全合一的code框架示例
      code:CppCOMClient)


  4.   
  5. 反向的PInvoke:托管code调用本地传递一个委托
      本地code可以打电话回来。
      (全合一的code框架示例
      code:CSPInvokeDll)


  6.   
  7. 如果含有天然VC ++ code模块允许使CLR ,本土VC ++ code可拨打
      可直接通过它的.NET程序集
      只是工程或IJW机制。 (全合一的code框架示例code:CppCLIWrapLib)


  8.   

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.

  1. Native VC++ module calls CLR Hosting APIs to host CLR, load and call the .NET assembly. (All-In-One Code Framework Sample Code: CppHostCLR)

  2. 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)

  3. Reverse PInvoke: the managed code call native passing a delegate the native code can call back. (All-In-One Code Framework Sample Code: CSPInvokeDll)

  4. 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屋!

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