如何使用C#和.NET中的C ++库? [英] How do I use a C++ library from C# and .NET?

查看:122
本文介绍了如何使用C#和.NET中的C ++库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与DLL如何导出C ++类和通用方法(wrt C ++语言特性没有C#并行)密切相关。



我相信你可以通过引用该DLL并使用C#来调用C#中的一个 externC dllimport的。但是可以实例化一个模板化的C ++类型吗?如果C ++类型在C#中不支持某些疯狂的怎么办?是否有RFC或相关部分的 C#规范



感谢...



编辑:我现在偶然发现 P / Invoke ,这应该是有价值的,但我仍然在寻找关于这个的规范或标准。

解决方案

完美的方法是使用托管c ++访问非托管的C ++并编译到程序集中。


My question is closely related to how a DLL exports C++ classes and generic methods (wrt C++ language features without a C# parallel).

I believe you can call functions inside an extern "C" block from C# by just referencing the DLL and using DLLImport. But can you instantiate a templated C++ type? What if the C++ type does somethin' crazy that's not supported in C#? Is there an RFC or relevant part of the C# specification?

Thanks...

EDIT: I now stumbled across P/Invoke which should be valuable, but I'm still looking for a specification or standard regarding this.

解决方案

The sane way to do it is to use managed c++ to access unmanaged c++ and compile into an assembly.

这篇关于如何使用C#和.NET中的C ++库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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