This is a follow-up to a previous question Is it possible to switch DLLs at runtime so as to use a different version?.
Since posting that question I have reorganised my project but am still have DLL loading problems.
I have 3 main projects: the application, a library containing MEF plugins and a second library containing more MEF plugins. Each plugin handles a type of IO device.
The manufacturer of one of the devices has produced a new set of identically named but incompatible DLLs. I now have 2 plugins to handle each version and put them in 2 separate projects (MEF Lib1 & MEF Lib2).
The MEF loader decides which one of the conflicting plugins to load (only one is needed) and the plugin is told to initialise itself. It then copies its' DLLs (managed and unmanaged) to the execution folder before the DLLs are accessed.
This does not work as desired. The managed DLLs are correct but the unmanaged DLL that actually gets loaded is an older version.
I have tried using the AppDomain.AssemblyResolve
event but this only seems to be activated when a DLL cannot be found. In my case, the DLL is always found - just not the one I want.
What am I doing wrong?