使用C ++在C#API [英] Using C++ API in C#
问题描述
我想使用是用C ++的API。它涉及包括头文件和库。我如何使用这个API在C#应用程序?
I would like to use an API that is written in c++. It involves including header files and libraries. How can I use this API in a C# application?
推荐答案
最简单的方法是在的 C ++ / CLI 。这允许你混合的非托管接口和管理code一起这样你就可以翻译非托管API到一些在管理code消耗品。
The easiest way is to write a 'shim' assembly in C++/CLI. This lets you mix the unmanaged interface and managed code together so you can 'translate' the unmanaged API into some that is consumable in managed code.
有很多资源在那里,对于深入概述,请参阅 C ++ / CLI理由并为互操作问题的讨论试穿的。NET和C ++桥。
There are lots of resources out there, for an in depth overview see C++/CLI Rationale and for a discussion of the interop issues try this post on a .NET to C++ Bridge.
这篇关于使用C ++在C#API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!