I'm triggering AssemblyResolve by setting "Copy Local" of a particular DLL to false. My AssemblyResolve gets triggered, and I get to choose the location of my DLL.
Later in the code, I want AssemblyResolve to re-trigger so I can specify a new DLL location, but since the DLL from the first AssemblyResolve was loaded successfully, I can't reload a new DLL.
Is there a way I can clear the current DLL and reload it? Or something like that???
Thanks!
You have to use Assembly.LoadFile() to accomplish that. You can't do it with AssemblyResolve, the CLR very carefully avoids re-loading assemblies since that would open the door to mixing different versions of the same class. With some methods jitted against one version, some against another. Without any way to guarantee which, hilarity ensues.
LoadFile() is however a gun that shoots your foot and blows up in your face in very creative and hard to diagnose ways. One joy is that the exact same type is incompatible when loaded twice. You'd better rethink this.