在开发机器上安装VS2012 Premium后,单元测试失败,因此开发人员修复了该问题.当更改被推送到TeamCity时,单元测试失败.除了升级的解决方案文件与VS2012兼容之外,项目没有改变.它仍然以.net框架4.0为目标
我已经将问题隔离到unicode字符在调用时被转义的问题Uri.ToString.以下代码复制了该行为.
Imports NUnit.Framework
<TestFixture()>
Public Class UriTest
<Test()>
Public Sub UriToStringUrlDecodes()
Dim uri = New Uri("http://www.example.org/test?helloworld=foo%B6bar")
Assert.AreEqual("http://www.example.org/test?helloworld=foo¶bar", uri.ToString())
End Sub
End Class
Run Code Online (Sandbox Code Playgroud)
在没有安装VS2012的机器上在VS2010中运行此功能成功,在安装了VS2012的机器上的VS2010中运行此功能失败.两者都使用最新版本的NCrunch和NuGet的NUnit.


来自失败断言的消息是
Expected string length 46 but was 48. Strings differ at index 42.
Expected: "http://www.example.org/test?helloworld=foo¶bar"
But was: "http://www.example.org/test?helloworld=foo%B6bar"
-----------------------------------------------------^
Run Code Online (Sandbox Code Playgroud)
.NET 4和.NET 4.5 上的MSDN文档显示ToString不应对此字符进行编码,这意味着旧行为应该是正确的.
A String instance that contains the unescaped canonical representation of the Uri instance. All characters are unescaped except #, ?, and %.
Run Code Online (Sandbox Code Playgroud)
安装VS2012后,正在转义该unicode字符.
VS2012计算机上System.dll的文件版本为4.0.30319.17929
构建服务器上的System.dll的文件版本是4.0.30319.236
无视我们使用的原因 …
我正在尝试为URI类启用IDN/IRI支持,因为我需要德语umlaut-domains上的"Uri.IsWellFormedUriString"方法(例如www.bücher.de).
我在/sf/answers/427537771/上找到了类似的问题(摘自http://msdn.microsoft.com/en-us/library/system.uri.aspx "国际资源标识符支持")但解决方案对我不起作用.我当前的app.config文件看起来像这样:
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="..." type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<!-- ... some sections in here ... -->
</sectionGroup>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<!-- ... some sections in here ... -->
</sectionGroup>
</configSections>
<userSettings>
<!-- ... some settings in here ... -->
</userSettings>
<applicationSettings>
<!-- ... some settings in here ... -->
</applicationSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
当我刚补充
<uri>
<idn enabled="All" />
<iriParsing …Run Code Online (Sandbox Code Playgroud)