I have a .NET application and need to load a native library whose location is specified by the user. PInvoke looks like it'll only load from the global search paths (or a path specified at compile time?). Would the best method be to create a C++/CLI assembly which calls LoadLibrary at runtime?
Would C++/CLI be simpler than C# PInvoking LoadLibrary?
I agree with JaredPar. Once you have the dll loaded you'll need to access the API exposed by the dll using function pointers simple PInvoke declarations will not work any longer you will need to use the windows API GetProcAddress...
...and then bind the returned address to a delegate using GetDelegateForFunctionPointer() in the System.Runtime.InteropServices namespace.
If you already have a C#/VB.Net project it would be much simpler to just PInvoke LoadLibrary in order to get a DLL to load. It takes one quick PInvoke call from the existing dll
Just adding this code would be much faster than adding a full C++\CLI project.