I have an SDK for a USB-connected camera. This is a 32-bit, unmanaged, c or c++ dll, with no source code. It comes with an import library (.lib file), several c/c++ header files, and virtually no documentation.
I am writing a WPF application that I want to use to call the API methods in the SDK. As I understand it, I need to write a C++/CLI 'wrapper' class library to make the methods in the SDK DLL accessible to the C# application.
I have been working on this for several days, and have read literally hundreds of articles/texts/etc. on StackOverflow, Microsoft documentation pages, and dozens of other sources. I just keep running into one problem after another, and all the resources I've found seem to be missing some critical piece of the puzzle.
I apologize for the way I am presenting this, but here are some of the questions I have:
Do I need to "Copy Always" or "Copy if Newer" the API dll to the $Solution folder?
Do I need a Reference in the Wrapper project to reference the API dll?
In the wrapper, do I need to specify an 'extern' declaration to API methods?
In the wrapper, do I need to specify an 'extern "C"' declaration to API methods?
Do I use PInvoke to call API methods?
Do I use the DllImportAttribute to tell where to find the API method?
Do I need to specify the Calling Convention for the API method?
Do I need to use LoadLibrary to get access to the API dll?
Do I need to link to a static .lib (import library) file from my Wrapper project?
Does the Project Platform of my Wrapper need to be x86 (for a 32-bit API dll)?
Can the Project Platform for the C# .NET app be "Any CPU"?
Will the JIT compiler figure out at runtime what platform to compile to?
Is 'Marshaling' required between the C# app and the managed c++/CLI Wrapper?
Is 'Marshaling' required between the managed c++/CLI Wrapper and the unmanaged API dll?
Is COM required for a c# app to use an unmanaged c/c++ .dll library?
Do I need to use System.Runtime.InteropServices?
Do I need to set "prefer 32-bit" on the solution or either of the projects?