c# – 通用Windows应用程序项目中的MSBuild错误
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – 通用Windows应用程序项目中的MSBuild错误,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2736字,纯文字阅读大概需要4分钟。
内容图文
![c# – 通用Windows应用程序项目中的MSBuild错误](/upload/InfoBanner/zyjiaocheng/965/04602e93510f4e3d8230401eb82d37d6.jpg)
我目前在使用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或ApplicationDefinition的单个空XAML文件足以显示此错误.
进一步查看诊断日志似乎在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(或命令行)
解决方法:
在Chris W.的评论中,在this article的帮助下,我能够弄明白.在这种情况下,错误表示项目中的ResourceDictionary之一存在问题.
事实证明,我的项目中的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相关问题(模板上的无效事件处理程序等)引起.
内容总结
以上是互联网集市为您收集整理的c# – 通用Windows应用程序项目中的MSBuild错误全部内容,希望文章能够帮你解决c# – 通用Windows应用程序项目中的MSBuild错误所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。