Resolving Assemblies, the fuzzy way

Posted by David Rutten on Stack Overflow See other posts from Stack Overflow or by David Rutten
Published on 2010-04-28T12:42:50Z Indexed on 2010/04/28 19:27 UTC
Read the original article Hit count: 248

Here's the setup:

A pure DotNET class library is loaded by an unmanaged desktop application. The Class Library acts as a plugin. This plugin loads little baby plugins of its own (all DotNET Class Libraries), and it does so by reading the dll into memory as a byte-stream, then

Assembly asm = Assembly.Load(COFF_Image);

The problem arises when those little baby plugins have references to other dlls. Since they are loaded via the memory rather than directly from the disk, the framework often cannot find these referenced assemblies and is thus incapable of loading them.

I can add an AssemblyResolver handler to my project and I can see these referenced assemblies drop past. I have a reasonably good idea about where to find these referenced assemblies on the disk, but how can I make sure that the Assmebly I load is the correct one?

In short, how do I reliably go from the System.ResolveEventArgs.Name field to a dll file path, presuming I have a list of all the folders where this dll could be hiding)?

© Stack Overflow or respective owner

Related posts about c#

Related posts about assemblies