如何在C#应用程序中使用* .lib文件? [英] How to use *.lib file in C# application?

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

问题描述

所以我有一些.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:


平台调用教程

Platform Invoke Tutorial

如果要生成包装器,您可能需要查看 P /在CodePlex上调用Interop Assistant 。请注意,此工具适用于原始的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文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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