如何使用方法从C ++ DLL在C#中枚举 [英] How to use methods & enum in c# from c++ DLL
本文介绍了如何使用方法从C ++ DLL在C#中枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个用c ++编写的dll.它具有枚举,方法,属性等.
我想在c#应用程序中使用它们.
因此,我应该怎么做?
I have two dll''s which are written in c++.It has enum ,method,properties etc..
I want to use them in c# application.
So what I should do?
推荐答案
如果这是纯本地C ++(不是C ++/CLI),则只能将方法与P/Invoke一起使用.请参阅:
http://en.wikipedia.org/wiki/P/invoke [ http://msdn.microsoft.com/library/en-us/vcmxspec/html/vcmg_PlatformInvocationServices.asp [^ ].
此CodeProject文章也可能有用:
基本P/调用 [ http://en.wikipedia.org/wiki/C%2B%2B/CLI [ ^ ],
http://www.gotw.ca/publications/C++CLIRationale.pdf [ ^ ],
http://www.ecma-international.org/publications/standards/Ecma-372.htm [ ^ ].
-SA
If this is purely native C++ (not C++/CLI), you can use only the method with P/Invoke. Please see:
http://en.wikipedia.org/wiki/P/invoke[^],
http://msdn.microsoft.com/library/en-us/vcmxspec/html/vcmg_PlatformInvocationServices.asp[^].
This CodeProject article can also be useful:
Essential P/Invoke[^].
Sometimes you need much tighter integration. In this case, another approach could be beneficial: using C++/CLI and mixed-mode (managed + unmanages) project. Such project can use everything in C++ resources, as much as regular C++ could use, and all CLI types and members to the project, some of them wrapping unmanaged code. This way, you can create a class library using native C++, but used as a regular .NET assembly. You can reference this assembly as any other .NET assembly in your C# projects. Please see:
http://en.wikipedia.org/wiki/C%2B%2B/CLI[^],
http://www.gotw.ca/publications/C++CLIRationale.pdf[^],
http://www.ecma-international.org/publications/standards/Ecma-372.htm[^].
—SA
查看CP中的这篇文章是否对您有帮助: ^ ]
See if this article in CP helps you:Dynamic Invoke C++ DLL function in C#[^]
这篇关于如何使用方法从C ++ DLL在C#中枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文