I'm trying to load a few modules via hooking into the AppDomain.AssemblyResolve
and AppDomain.ReflectionOnlyAssemblyResolve
events. While I got the former to work, I fail miserably on the latter. I've boiled my problem down to this little program:
public static class AssemblyLoader
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve +=
ReflectionOnlyAssemblyResolve;
// fails with FileNotFoundException
Assembly.ReflectionOnlyLoad("Foo");
}
public static Assembly ReflectionOnlyAssemblyResolve(object sender,
ResolveEventArgs args)
{
Trace.TraceInformation(
"Failed resolving Assembly {0} for reflection", args.Name);
return null;
}
}
Running this program fails with a FileNotFoundException
when trying to Assembly.ReflectionOnlyLoad
, but it doesn't call the ReflectionOnlyAssemblyResolve handler. I'm pretty stumped there.
Does anybody have an idea what could be the root cause of this and how to get this to work?
Thanks!