So I have some .lib file (generated like this one) How to use it from my C# WPF application?
Asked
Active
Viewed 1.2k times
1 Answers
7
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:
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.

Community
- 1
- 1

Dirk Vollmar
- 172,527
- 53
- 255
- 316
-
and can .lib file at least help me in creating a wraper? – Rella May 17 '10 at 10:23
-
1If all you have is a .lib and .h file, you can create a dll wrapper for the lib, exporting the functions you need. – Stephen Cleary May 17 '10 at 12:54
-
@Stephen Cleary: As this is about using native code from C# the lib file will not be needed. All you will need is the method signature and the name of the native dll that contains the method. – Dirk Vollmar May 17 '10 at 13:42