[英]Cannot load a Strong name assembly by Assembly.LoadFrom(), call fails with 0x80004005 (E_FAIL)
我有一个Adobe acrobat插件,在AssemblyResolve事件中使用System.Reflection.Assembly.LoadFile(path),该事件在我尝试加载签名的程序集时都会失败。 错误是
The assembly with display name 'Microsoft.AspNet.SignalR.Client' failed to load in the 'Load' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNet.SignalR.Client, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
我必须使用AssemblyResolve事件,因为所需的程序集将位于Acrobat的exe下面几级的文件夹中。 这是AssebmlyResolve调用的代码。
Assembly^ TeamMateIntegrationManagedWrapper::ResolveAssembly(Object^ sender, ResolveEventArgs^ args){
try
{
// This method will be called if an assembly cannot be found.
// The assembly should be 2 folders below the current working directory where the Adobe Acrobat executable lives.
AppDomain^ appDomain = static_cast<AppDomain^>(sender);
String^ path = appDomain->BaseDirectory;
path += "plug_ins\\MyAppName\\" + args->Name->Split(',')[0] + ".dll";
return System::Reflection::Assembly::LoadFile(path);
}
catch (Exception^ ex)
{
String^ msg = ex->Message;
}
return nullptr;}
Acrobat插件主要使用C语言编写,但是具有CLI桥接类来包装使用SignalR的托管C#程序集。
我尝试过的事情。
Adobe Reader在启动时具有选项/首选项Edit-> Preferences->安全性(增强)->启用保护模式,可在受保护的沙箱中启动应用程序。 此保护可防止加载名为Strong的dll。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.