我写了一个自定义的AssemblyResolve方法来处理位于exe文件之外的文件夹中的程序集。但是它显示缺少"Microsoft.Practices.EnterpriseLibrary.Common.resources"。虽然我有Microsoft.Practices.EnterpriseLibrary.Common.dll,但我没有Microsoft.Practices.EnterpriseLibrary.Common.resources.dll。我该如何手动加载Microsoft.Practices.EnterpriseLibrary.Common.resources?
protected Assembly ConfigResolveEventHandler(object sender, ResolveEventArgs args)
{
//This handler is called only when the common language runtime tries to bind to the assembly and fails.
//Retrieve the list of referenced assemblies in an array of AssemblyName.
string strTempAssmbPath = "";
Assembly asm = this.GetType().Assembly;
var uri = new Uri(Path.GetDirectoryName(asm.CodeBase));
Assembly objExecutingAssemblies = Assembly.GetExecutingAssembly();
AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies();
//Loop through the array of referenced assembly names.
if (arrReferencedAssmbNames.Any(strAssmbName => strAssmbName.Name == args.Name))
{
strTempAssmbPath = Path.Combine(uri.LocalPath, args.Name) + ".dll";
}
//Load the assembly from the specified path.
Assembly myAssembly = Assembly.LoadFrom(strTempAssmbPath);
//Return the loaded assembly.
return myAssembly;
}
Microsoft.Practices.EnterpriseLibrary.Common.dll
库附带了一些资源,也许由于某种原因无法访问这些资源。在.NET Reflector中查看它时,它列出了引用,但未列出Microsoft.Practices.EnterpriseLibrary.Common.resources.dll
。你有解决这个问题的好运吗? - merthsoft