Create a new appdomain, setup the assemblyResolve handler and you always get an exception saying 'assembly [current executing assembly] not found'
what gives ? code is below
string _fileName = @"c:\temp\abc123.dll";
AppDomain sandBox = AppDomain.CreateDomain("sandbox");
sandBox.AssemblyResolve += new ResolveEventHandler(sandBox_AssemblyResolve);
// the line generates the exception !
System.Reflection.Assembly asm = sandBox.Load(System.Reflection.AssemblyName
.GetAssemblyName(fileName).FullName);
foreach (System.Reflection.AssemblyName ar in asm.GetReferencedAssemblies())
dbgWrite("Ref: " + ar.FullName );
System.Reflection.Assembly sandBox_AssemblyResolve
(object sender, ResolveEventArgs e)
{
System.Reflection.Assembly asm =
System.Reflection.Assembly.LoadFrom(_fileName);
return asm;
}
exception is:
System.IO.FileNotFoundException: Could not load file or assembly 'appAdmin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'appAdmin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' [snip]