我有一个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#程序集。
我尝试过的事情。
答案 0 :(得分:1)
Adobe Reader有一个选项/首选项Edit-&gt; Preferences-&gt; Security(Enhanced) - &gt;启动时启用保护模式,在受保护的沙箱中启动应用程序。这种保护阻止了强名称dll的加载。