Search code examples
c#winformswindows-forms-designer.lib

How to import ".lib" file into C# windows-forms


I am new to C# windows-forms development.

I study the Dante API(DAPI) and I am trying to make a simple windows-forms GUI to check the Dante device name.

After installing the DAPI SDK, I got a lib folder, all the folder has inside is Win32 or x64 "*.lib" files and I have got an include folder with "*.h" header files. (I guess this API is C language based.)

I googled some keywords like "C# windows form import the .lib", and the answer was "using P/Invoke", but most of it is calling a "*.dll" file.

So I am confused, can P/Invoke be used in the C# windows-forms and import ".lib" file? or there is there another way to do this task?

If there are some ways can import the ".lib" into the C# windows-form, any simple examples can show me how to call the function from the lib?

My environment: Visual Studio 2022 express


Solution

  • If you have been given a .h file and a .lib file, it's likely that you're meant to use those in a c++ project, not in c#. The .lib file is linked statically at compile time-- it is not a dynamic link library. So you can't call it with p/invoke.

    If possible, go back to the source and see if there is a managed wrapper for the library. Otherwise you will need to create one yourself. See this question to see how someone else did it.