VS2008 Windows Forms I am looking into dynamically loading assemblies, and possibly storing the assembly code somewhere other than a .dll file (e.g. in a database). I can easily get the contents of the DLL into a byte array, and I can then use Assembly.Load to load the aasembly. I can then create objects using CreateInstance. So far, so good. However I have a problem with some DLLs that reference other DLLs. DLL1 references DLL2, so I use Assembly.Load to load DLL2 and then again to load DLL1. This all seems to work without errors. I can use CreateInstance to create an object from DLL1, and this seems to work too. However, if I delete the original dlls, as soon as I try to call a method on this object, I get a FileNotFoundException trying to load DLL2. It seems to be trying to load DLL2 from the dll file. Why is it doing this when I have already loaded the DLL? How do I get it to use the assembly that I have already loaded? Any suggestions appreciated. Thanks Phil.
Found it. I just need to handle the AppDomain.AssemblyResolve event, and load the dependent dll assemblies in there.