问题描述
所以我有一些.lib文件(生成像)如何使用它从我的C# WPF应用程序?
So I have some .lib file (generated like this one) How to use it from my C# WPF application?
推荐答案
当您要使用C#中的本机库时,不需要.lib文件。在.NET中处理的方式是使用Platform Invoke(P / Invoke)。我建议你遵循MSDN上的教程,它将让你开始:
When you want to use native libraries from C# you won't need a .lib file. The way this is handled in .NET is by using Platform Invoke (P/Invoke). I suggest you follow the tutorial on MSDN, it will get you started:
如果要生成包装器,您可能需要查看 。请注意,此工具适用于原始的C / C ++代码。使用.dll文件创建包装器是不可行的,因为本机DLL不存储导出函数的签名(如),一个lib文件将以编译器的特定方式存储签名。
If you want to generate a wrapper you might want to have a look at the P/Invoke Interop Assistant on CodePlex. Please note that this tool works on the original C/C++ code. Using a .dll file to create a wrapper is not feasible because native DLLs don't store the signature of the exported functions (as described in this thread) and a lib file will store the signature in a compiler specific way.
这篇关于如何在C#应用程序中使用* .lib文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!