I am developing a .NET application that uses reflection to load plugins. My plugins are C# class libraries. The trouble is that some of my plugins reference conventional Win32 DLLs, and C# is blindly attempting to load the dependencies as if they were .NET DLLs.
Here is how I load a plugin:
string fileName = "plugin.dll";
Assembly.LoadFrom(fileName);
I get a System.BadImageFormatException
with the following message:
Could not load file or assembly 'plugin.dll' or one of its dependencies.
The module was expected to contain an assembly manifest.
How do I programmatically load an assembly that references Win32 DLLs?