8

私には、しばらくの間頭を悩ませている問題があります。私がリリースした WPF/.NET 3.5 製品では、次のエラーが原因で、100 回のインストールのうち約 1 回でソフトウェアをまったく実行できません。

System.Windows.Markup.XamlParseException: オブジェクトの初期化に失敗しました (ISupportInitialize.EndInit)。見つかったアセンブリのマニフェスト定義がアセンブリ参照と一致しません。(HRESULT からの例外: 0x80131040) マークアップ ファイル 'mainwindow.xaml' のオブジェクト 'System.Windows.Controls.MenuItem' でエラーが発生しました。

これは、次の 3 つの理由で不可解です。

  1. これは、インストールの約 1 ~ 2% でのみ発生します。

  2. これらのシステムの .NET インストールまたは OS について、私が知る限り、何も異常はありません。

  3. これは、既定のフレームワーク参照 (System.Windows.Controls.MenuItem) で発生しています。

誰でもこれの考えられる原因を考えることができますか?

編集:「500」のヒントに従った後、顧客のマシンで Fusion ログ ビューアーを実行できました。開発マシンと他のすべてのテスト マシンでは、"PresentationFramework" と "PresentationFramework.Aero" に対するバインディングの試みが成功しています。クライアント マシンでは、失敗する追加のバインド試行があります (無関係な行が削除されています)。

*** Assembly Binder Log Entry  (2/3/2013 @ 1:18:44 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = PresentationFramework.Dawn TOP, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: PresentationFramework.Dawn TOP, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/My App/PresentationFramework.Dawn TOP.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/My App/PresentationFramework.Dawn TOP/PresentationFramework.Dawn TOP.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/My App/PresentationFramework.Dawn TOP.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/My App/PresentationFramework.Dawn TOP/PresentationFramework.Dawn TOP.EXE.
LOG: All probing URLs attempted and failed.

「PresentationFramework.Dawn」を Google で検索しても結果が返されず、このファイルへの参照が見つかりません。実行できる説明または追加のテストはありますか?

編集 2: お客様が「Dusk」と呼ばれる非公式の Windows 7 Aero テーマをインストールしていたことが判明しました。何らかの理由で、PresentationFramework は、PresentationFramework.Aero ではなく、PresentationFramework.Dusk を呼び出すことにしました (プロジェクトに明示的に含めた参照)。DuskがGACで見つからないため、エラーはサードパーティのテーマの不適切なインストールの結果であると想定していますが、参照の試行を停止し、すべてのGUI要素を強制する方法について何か光を当てることができますか? PresentationFramework.Aero を使用しますか?

4

2 に答える 2

3

アプリケーションでは、システム テーマ以外のテーマを強制するために使用するテーマを指定できます。

このコードを ApplicationStartUp イベントに追加する必要があります

void App_Startup(object sender, StartupEventArgs e) {
  // other startup code
  Uri uri = new Uri(“PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\\themes/aero.normalcolor.xaml”, UriKind.Relative);

  Resources.MergedDictionaries.Add(Application.LoadComponent(uri) as ResourceDictionary);
}

XAML でテーマを定義することもできます。

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source=“/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\themes/aero.normalcolor.xaml“ />
        </ResourceDictionary.MergedDictionaries>

        <!– other resources go here –&gt;

    </ResourceDictionary>
</Application.Resources>

この設定は、Aero テーマを使用することを定義します。(使用するバージョンと公開鍵トークンを変更する必要があるかもしれません)。

詳細については、こちらをご覧ください

于 2013-02-07T07:46:03.553 に答える
3

失敗したマシンで、Assembly Binding Log Viewerを実行して、正常に動作しない理由をよりよく理解してください。

于 2013-02-01T18:02:50.070 に答える