.net “EnsureBindingRedirects”任务意外失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16832256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The "EnsureBindingRedirects" task failed unexpectedly
提问by Ivan Lewis
When I create new ASP.NET 4.5web forms application from vs2012and update all nugetpackages, I receive this error on build:
当我ASP.NET 4.5从vs2012所有nuget包创建新的Web 表单应用程序并更新所有包时,我在构建时收到此错误:
Error 1 The "EnsureBindingRedirects" task failed unexpectedly. System.NullReferenceException: Object reference not set to an instance of an object. at Roxel.BuildTasks.EnsureBindingRedirects.MergeBindingRedirectsFromElements(IEnumerable`1 dependentAssemblies) at Roxel.BuildTasks.EnsureBindingRedirects.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext()
错误 1 “EnsureBindingRedirects”任务意外失败。System.NullReferenceException:未将对象引用设置为对象的实例。在 Roxel.BuildTasks.EnsureBindingRedirects.MergeBindingRedirectsFromElements(IEnumerable`1dependentAssemblies) 在 Roxel.BuildTasks.EnsureBindingRedirects.Execute() 在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 在 Microsoft.Build.BackEnd .TaskBuilder.d__20.MoveNext()
回答by Henrik Fransas
It's a bug in Microsoft.Bcl.Buildand to solve it you have to put cultureinfo in the assemblyIdentity-part of web.configor app.config.
这是在一个错误Microsoft.Bcl.Build并解决它,你必须把culture信息中assemblyIdentity的双组分web.config或app.config。
For example if you have:
例如,如果您有:
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
change it to:
将其更改为:
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
回答by JHo
I had this error but slightly different, took me 45 minutes to figure it out so thought I'd better get this out there.
我有这个错误,但略有不同,我花了 45 分钟才弄明白,所以我想我最好把它弄出来。
Was experiencing the "EnsureBindingRedirects" task failed unexpectedlyproblem but mine came from an XmlException:
遇到了这个"EnsureBindingRedirects" task failed unexpectedly问题,但我的来自 XmlException:
(...)\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets(97,5): error MSB4018: System.Xml.XmlException: '=' is an unexpected token. The expected token is ';'. Line 39, position 175.
(...)\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets(97,5): 错误 MSB4018: System.Xml.XmlException: '=' 是一个意外的标记。预期的标记是“;”。第 39 行,位置 175。
Turns out the cause was that I'd recently added an entry to my web.config's appSettingswhere the valuewas a URL that contained an ampersand (&).
原来的原因是我最近在我的 web.config 中添加了一个条目,appSettings其中value包含一个和号 (&) 的 URL。
Ampersands need to be escaped in XML, even in attribute values.
&符号需要在 XML 中进行转义,即使在属性值中也是如此。
I changed all the &in the URL value to &and it built without issue.
我&将 URL 值中的所有内容更改为,&并且它的构建没有问题。
回答by Volodymyr Bilyachat
In my case issue have revealed after I merged a branch which broke my web.configfile. It added comment character sequence <!--without closing part -->.
在我的情况下,在我合并了一个破坏我的web.config文件的分支后,问题就出现了。它添加了注释字符序列<!--而不关闭部分-->。
Making file markup valid fixed the issue.
使文件标记有效修复了该问题。
回答by Akira Yamamoto
Update Microsoft.Bcl.Buildto fix this.
更新Microsoft.Bcl.Build以解决此问题。
Run this on Package Manager console:
在包管理器控制台上运行:
Update-Package Microsoft.Bcl.Build
回答by Ron Cain
A new version of Microsoft.Bcl.Build (1.0.6) has been pushed up to NuGet.org to fix this problem. The workaround to add the culture to the assemblyIdentity is no longer necessary but won't hurt if you leave it in.
已将新版本的 Microsoft.Bcl.Build (1.0.6) 推送到 NuGet.org 以解决此问题。不再需要将文化添加到 assemblyIdentity 的解决方法,但如果您将其保留,则不会受到影响。
回答by Denys
The following steps can be performed to solve the issue:
可以执行以下步骤来解决该问题:
- Update the "Microsoft.Bcl.Build" package to the latest version.
- Make sure you have an App.config/Web.configfile under your project and it also exists physically in a relevant folder on your machine.
- Make sure there are no special characters in the App.config/Web.configfile. If they exist you need to replace them. Look at this article -> https://support.crossref.org/hc/en-us/articles/215652783-Special-characters-in-your-XML
- In App.config/Web.configfile under each
<dependentAssembly>add the following key-value pair:culture="neutral"to<assemblyIdentity ... />. - Another step that describes how to fix your unique case and has been not described above :)
- 将“Microsoft.Bcl.Build”包更新到最新版本。
- 确保您的项目下有一个App.config/Web.config文件,并且它也实际存在于您机器上的相关文件夹中。
- 确保App.config/Web.config文件中没有特殊字符。如果它们存在,您需要更换它们。看这篇文章-> https://support.crossref.org/hc/en-us/articles/215652783-Special-characters-in-your-XML
- 在App.config/Web.config文件中的每一个下
<dependentAssembly>添加以下键值对:culture="neutral"to<assemblyIdentity ... />. - 描述如何修复您的独特案例的另一个步骤,上面没有描述:)
I hope this helps.
我希望这有帮助。
回答by user761276
You have added a reference of a file which actually doesn't exists in your solution folder.
您添加了一个文件的引用,该文件实际上不存在于您的解决方案文件夹中。
回答by Eric
This happened to me when I had a BIN and OBJ folder marked read only. Remove the read-only on *.dll.config and *.app.config or delete those folders.
当我将 BIN 和 OBJ 文件夹标记为只读时,这发生在我身上。删除 *.dll.config 和 *.app.config 上的只读文件或删除这些文件夹。
回答by Vaggelis Stefanakis
My problem was that the tag was not on the first line of the file. Fixed that and everything worked ok.
我的问题是标签不在文件的第一行。解决了这个问题,一切正常。
回答by Shane Courtrille
My problem was due to an appSettings value in web.config which contained a url with a & character.
我的问题是由于 web.config 中的 appSettings 值包含一个带有 & 字符的 url。

