AssemblyResolve イベントで System.Reflection.Assembly.LoadFile(path) を使用する Adobe acrobat プラグインがあり、署名済みアセンブリを読み込もうとすると失敗します。エラーは
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))
必要なアセンブリは、Acrobat の exe の数レベル下のフォルダーに存在するため、AssemblyResolve イベントを使用する必要があります。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 ですが、SignalR を使用するマネージ C# アセンブリをラップする CLI ブリッジ クラスがあります。
私が試したこと。
- AssemblyResolve イベントを使用して回避するには、必要なすべての dll を Acrobat の実行可能ファイルと同じフォルダーに配置します。
- AssemblyResolve イベントで提供している dll の SignalR バージョンと PublicKeyToken が、ResolveEventArgs で要求されているものと正確に一致することを確認しました
- すべてのアセンブリ (プラグイン dll を含む) が .Net Framework v4.6 をターゲットにしており、プラグイン dll が x86 用にビルドされ、他のアセンブリが任意の CPU 用にビルドされていることを確認しました。
- Assembly::LoadFrom(path) を LoadFile(path) の代わりに試してみましたが、アセンブリの読み込み中に同じエラーが発生しました。
- ソース コードから SignalR を再構築し、厳密な名前を削除しました。AssebmlyResolve イベントで SignalR アセンブリが正常に読み込まれました。SignalR アセンブリに厳密な名前を追加すると、上記のエラーが再び発生しました。
- C# アセンブリに厳密な名前を追加すると、SignalR アセンブリと同じように上記と同じエラーが発生しました。
- Fusion ログ ビューアを確認しましたが、Acrobat のログはありませんでした。
- SignalR を使用する同じ C# アセンブリを使用する同じ CLI ブリッジ ラッパー クラスを含む C++ コンソール アプリケーションを作成しました。上記と同じエラーです。Fusion ログを確認しましたが、ConsoleApplication.exe フォルダーの下に Microsoft.AspNet.SignalR.dll のログはありません。SignalR を使用する C# アセンブリの fusino ログを調べましたが、ログ ファイルにロードしようとしている SignalR dll の参照/言及はありません。