4

現在、Visual Studio 2015 を使用してユニバーサル Windows アプリをビルドする際に問題が発生しています。プロジェクトをコンパイルしようとすると、次のエラーが発生します。

Child node "2" exited prematurely. Shutting down. Diagnostic information may be found in files in the temporary files directory named MSBuild_*.failure.txt.

このエラーは、アプリケーションに XAML ファイルが存在する場合に発生します。ファイルに何が含まれているかは問題ではありません。Pageこのエラーを表示するには、ビルド アクションがまたはに設定された単一の空の XAML ファイルでApplicationDefinition十分です。

診断ログをさらに調べるCompileXamlと、次の例外を伴うタスクでエラーが発生しているようです。

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Microsoft.Windows.UI.Xaml.Build.Tasks.NativeMethods.WriteWithCheckSum(IStream[] xamlStreams, Int32 numFiles, String[] pbChecksum, Int32 checksumSize, IXbfMetadataProvider provider, TargetOSVersion targetVersion, UInt32 xbfGenerationFlags, IStream[] xbfStreams, Int32& errorCode, Int32& errorFileIndex, Int32& errorLine, Int32& errorColumn)
   at Microsoft.Xaml.XBF.XbfGenerator.GenerateXbfFromStreams(IStream[] inputStreams, IStream[] outputStreams, UInt32 xbfGenerationFlags, String[] checksums, TargetOSVersion targetOS, Int32& errorCode, Int32& errorFile, Int32& errorLine, Int32& errorPosition)
   at Microsoft.Xaml.XBF.XbfGenerator.GenerateAll(String targetPlatformVersion, UInt32 xbfGenerationFlags)
   at Microsoft.Xaml.XBF.XbfGenerator.GenerateXbfFiles(String targetPlatformVersion, UInt32 xbfGenerationFlags, Boolean v80Compat)
   at Microsoft.Windows.UI.Xaml.Build.Tasks.CompileXamlInternal.GenerateXbfFiles(List`1 xamlList)
   at Microsoft.Windows.UI.Xaml.Build.Tasks.CompileXamlInternal.DoExecute()
   at Microsoft.Windows.UI.Xaml.Build.Tasks.CompileXaml.Execute()

この例外の原因は何ですか?

トラブルシューティングの手順は既に実行されていますが、役に立ちません:

  • パソコンの再起動
  • Visual Studio と .NET Framework の再インストール
  • コマンドラインからのビルド
  • 管理者として VS (またはコマンド ライン) を起動する
4

1 に答える 1

2

Chris W. のコメントにリンクされているこの記事の助けを借りて、私はそれを理解することができました。この場合、エラーはResourceDictionaryプロジェクト内のいずれかの問題を示しています。

私のプロジェクトの 1 つにResourceDictionary重複した名前空間宣言が含まれていることがわかりました。

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp.UAP.Base">

    <Style TargetType="local:TTBasePage"  xmlns:local="using:MyApp.UAP.Base"> <!-- This line caused  the error -->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:TTBasePage">
                    <Border
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

この重複した名前空間宣言を削除すると、ビルド エラーが解決されました。

記事によると、他のResourceDictionary関連する問題 (テンプレートの無効なイベントハンドラーなど) が原因である可能性もあります。

于 2015-12-08T08:50:45.193 に答える