从C#类库导出函数 [英] Exporting functions from a C# class library

查看:244
本文介绍了从C#类库导出函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何导出C#类库中定义的函数,同时使其能够导入到非托管C ++应用程序/ DLL中调用?

解决方案严格来说,你不能像传统的.dll那样导出函数,因为.NET .dll根本不是真的.dll的。您只有三个选项是:


  1. 使用托管C ++

  2. 将C#类暴露为COM对象,从您的C ++代码中使用它们

  3. 主机您的C ++项目中的.NET运行时,并通过它与您的C#类交互。


How would I export functions defined in a C# class library, while enabling them to be imported to and called from an unmanaged C++ application/DLL ?

解决方案

Strictly speaking, you can't just export functions as you would in a classic .dll, as .NET .dll's aren't really .dll's at all. Your only three options are:

  1. Use managed C++
  2. Expose your C# classes as COM objects and consume them from your C++ code
  3. Host the .NET runtime in your C++ project and interact with your C# classes through that.

这篇关于从C#类库导出函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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