生成WPF应用程序时Microsoft.Build.BuildEngine.Engine引发错误 [英] Microsoft.Build.BuildEngine.Engine throws error when building WPF application

查看:179
本文介绍了生成WPF应用程序时Microsoft.Build.BuildEngine.Engine引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Microsoft.Build.BuildEngine.Engine来构建WPF应用程序.对于类库和Web应用程序,此操作已成功完成,但是现在尝试使用它来构建WPF应用程序时,出现以下错误:

I am using Microsoft.Build.BuildEngine.Engine to build a WPF application. This has been working successfully for class libraries and web applications, but now trying to use it to build a WPF application I am getting the following error:

目标MarkupCompilePass1: c:\ Windows \ Microsoft.NET \ Framework \ v3.5 \ Microsoft.WinFX.targets(294,9): 错误MC1000:未知的生成错误, 'API限制:程序集 'file:///C:\ Program文件 (x86)\参考 程序集\ Microsoft \ Framework \ v3.0 \ PresentationCore.dll' 已经从其他加载 地点.无法从 同一地点的新位置 应用程序域."完成目标 项目中的"MarkupCompilePass1" "TestWindowsApplication.csproj"- 失败.

Target MarkupCompilePass1: c:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.WinFX.targets(294,9): error MC1000: Unknown build error, 'API restriction: The assembly 'file:///C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll' has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.' Done building target "MarkupCompilePass1" in project "TestWindowsApplication.csproj" -- FAILED.

使用VisualStudio 2008进行构建(即通过菜单进行构建)时,此应用程序的构建情况良好,但是使用Microsoft.Build.BuildEngine.Engine会引发此构建错误.有人知道这是怎么回事吗?

This application builds fine when building using VisualStudio 2008 (i.e. build from the menu), but using the Microsoft.Build.BuildEngine.Engine it throws this build error. Anyone know what is going on here?

推荐答案

我遇到了同样的问题,发现

I had the same problem and found this on msdn which says

默认情况下,标记编译在 与MSBuild相同的AppDomain 引擎.这为我们提供了重要的 性能提升.这种行为可以 被切换 AlwaysCompileMarkupFilesInSeparateDomain 财产.后者有 卸载所有参考的优势 通过卸载单独的组件 AppDomain.

By default, markup compilation runs in the same AppDomain as the MSBuild engine. This provides us significant performance gains. This behavior can be toggled with the AlwaysCompileMarkupFilesInSeparateDomain property. The latter one has the advantage of unloading all reference assemblies by unloading the separate AppDomain.

因此,由于抛出的异常表明PresentationCore已加载到同一AppDomain中,因此我使用以下命令切换了此属性:

So since the exception thrown stated that PresentationCore was loaded in the same AppDomain I switched this property using:

projectToBuild.SetProperty("AlwaysCompileMarkupFilesInSeparateDomain", "True");

这似乎是关键.

我希望这会有所帮助.

这篇关于生成WPF应用程序时Microsoft.Build.BuildEngine.Engine引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆