Here's a snippet of code showing how AssemblyResolve can be used to solve your assembly (according to Reed Copey):
// register to listen to all assembly resolving attempts: AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler); // Check whether the desired assembly is already loaded private static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) { string desiredAssmebly = args.Name; if (desiredAssembly.Equals("NameUsedToLoadMyAssembly")){ return Assembly.LoadFrom(myAssemblyPath); } return null; }
Also note that the MSDN page for AssemblyResolve states that:
Starting with the .NET Framework version 4, the ResolveEventArgs.RequestingAssembly property returns the assembly that requested the assembly, which might not have resolved ...
This can be used if you know your assembly location compared to the assembly request.
Hershi
source share