必须使用C#DLL调用C ++的dll?DLL、dll

2023-09-03 04:09:15 作者:人已去〆梦已醒

我必须创建一个C#DLL调用C ++ DLL或我可以直接从我的C#应用​​程序调用它?

Do I have to create a C# DLL to call C++ DLL or I can call it directly from my C# application?

推荐答案

您可以直接调用它的使用的PInvoke和的DllImport 属性。假设,当然,它有标准的C入口点,没有编译器特有的C ++入口点。

You can call it directly with PInvoke and the DllImport attribute. Assuming, of course, that it has standard C entry points, not compiler-specific C++ entry points.

除非你在谈论C ++ / CLI,你会在这种情况下,引用.NET的DLL完全按照自己的引用任何其他.NET的DLL。

Unless you were talking about C++/CLI, in which case you would reference the .NET DLL exactly as you would reference any other .NET DLL.