I am hoping this is a simple question but I have not been able to find the solution in my searching. I have a C# application that needs to load data from several DLLs. Each DLL is guaranteed to have the same function foo(). But I want these DLLs to be plug and play at run time. The way I usually handle DLLs (where I know the name) is using:
[DllImport("my_dll.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int foo();
How do I do this with a dynamic string for a file name instead (e.g., "my_dll_3934.dll")? Also, there may be more than 1 dll that must be loaded that matches the same signature (e.g., "my_dll_3934.dll" and "my_dll_3935.dll").
The DLLs that will be used are generated by me but I want the end-user to just drop the DLL in as updates/new dlls become available without updating the application. I will be doing appropriate error checking and exception handling.
Thank you in advance.