我目前在使用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文件时,就会出现此错误。无论这些文件包含什么内容都不重要。一个单独的空XAML文件,其构建操作设置为Page
或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框架
- 从命令行构建
- 以管理员身份启动VS(或命令行)