I have a Blazor server x86 project that requires a 32-bit native DLL (native.dll). In a class wrapper I use DllImport as follows:
[DllImport("native.dll")]
internal static extern int Method1();
[DllImport("Native.dll, CharSet=CharSet.Unicode")]
internal static extern int Method2(string countryName, string abbreviation, int i);
In a Razor component, I load the DLL as follows (the DLL is marked "Copy to output always"):
IntPtr ptr = NativeLibrary.Load("native.dll");
The DLL loads fine and the first call to Method1 works great. But when I call Method2, I get a DLLNotFoundException (Unable to load DLL 'native.dll, CharSet=CharSet.Unicode' or one of its dependencies). Using DumpBin I determined that the native.dll has three dependencies: kernel32.dll, user32.dll and advapi32.dll. These, of course, have their own dependencies. I have tried adding Windows\SysWOW64 to the PATH, but no help, and should not have to do that anyway. How do I tell the app to include, or find, the native dependencies?