[英]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.