.Net Framework 4 を使用する従来の c# アプリケーションを使用しています。このアプリケーションは WebBrowser コントロールを使用し、「Microsoft HTML Object Library」(mshtml) を参照します。現在のバージョンは Server 2003 に展開され、.Net Framework 2 SDK がインストールされている場合にのみ実行されます。
プッシュは、アプリをサーバー 2008 にデプロイすることですが、フレームワーク SDK は使用しません。しかし、もちろん、アプリは実行されません。生成されるエラーは、「タイプ 'System.__ComObject' の COM オブジェクトをクラス タイプ 'mshtml.HTMLFormElementClass' にキャストできません」です。この特定のエラーは、インターフェイスにキャストすることで解決できることを認識しています。実際、この変更を行ったところ、アプリは次の mshtml キャスト エラーまで実行されました。アプリケーション全体に 200 行を超える同様のコードがあり、加えられた変更をテストする適切な方法がありません。
Fusion Log Viewer を使用して、読み込まれている依存関係を把握し、Visual Studio 2010 からアプリを起動したとき、またはシステム管理者が発見したように Visual Studio 2010 がインストールされている場合に、mshtml によって CustomMarshalers が読み込まれていることを発見しました。アプリを起動する前のサーバー 2008。私の直感は、Visual Studio の存在に関係なく、CustomMarshaler を読み込むには mshtml が必要だということです。
mshtml が CustomMarshallers をロードする Visual Studio の原因は何ですか? コードからこれを実現するにはどうすればよいですか?
CustomMarshallers の Fusion ログ ビューアー エントリ:
*** Assembly Binder Log Entry (11/24/2014 @ 1:42:11 PM) ***
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Users\[user]\Documents\[app]\Code\[app]\bin\Debug\[app].exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = [domain]\[user]
LOG: DisplayName = CustomMarshalers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/[user]/Documents/[app]/Code/[app]/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = [app].exe
Calling assembly : Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\[user]\Documents\[app]\Code\[app]\bin\Debug\[app].exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: CustomMarshalers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\Windows\Microsoft.Net\assembly\GAC_32\CustomMarshalers\v4.0_4.0.0.0__b03f5f7f11d50a3a\CustomMarshalers.dll.
LOG: Assembly is loaded in default load context.
*** Assembly Binder Log Entry (11/24/2014 @ 1:42:11 PM) ***
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Users\[user]\Documents\[app]\Code\[app]\bin\Debug\[app].exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = [domain]\[user]
LOG: DisplayName = CustomMarshalers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/[user]/Documents/[app]/Code/[app]/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = [app].exe
Calling assembly : Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\[user]\Documents\[app]\Code\[app]\bin\Debug\[app].exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: CustomMarshalers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\Windows\Microsoft.Net\assembly\GAC_32\CustomMarshalers\v4.0_4.0.0.0__b03f5f7f11d50a3a\CustomMarshalers.dll.
LOG: Assembly is loaded in default load context.