I'm trying to use AppDomain.AssemblyResolve
event to handle exceptions while resolving Assemblies of some dll loaded at runtime (SerializationException for dynamically loaded Type).
When the event is fired, I load all DLLs in my directory and create an Assembly
array, then I use this method to get the Assembly
containing the type I specify:
public static Assembly GetAssemblyContainingType(String completeTypeName,
Assembly[] assemblies)
{
Assembly assembly = null;
foreach (Assembly currentassembly in assemblies)
{
Type t = currentassembly.GetType(completeTypeName, false, true);
if (t != null)
{
assembly = currentassembly;
break;
}
}
return assembly;
}
The problem is that this code works only with an AssemblyQualifiedName
, and the ResolveEventArgs.Name
provided by the event is not so useful.
Can you suggest me some workaround?
Is there a way to pass some other arguments to the event when it is fired?