【发布时间】:2015-07-08 00:35:38
【问题描述】:
TeamCity 9 和 NUnit 2.6.4 在运行测试时出现问题,在本地一切正常。问题似乎与对 Newtonsoft.Json 的引用(像往常一样)。
Test(s) failed. System.IO.FileLoadException : Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter..ctor()
at System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor()
at System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters()
at System.Web.Http.HttpConfiguration.DefaultFormatters(HttpConfiguration config)
at System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes)
at MyCompany.Testing.WebAPI.ControllerTestAssistant.PrepareActionContext(HttpRequestMessage request, IHttpController controller)
at MyCompany.Web.Http.HttpResponseBuilderTests.PrepareActionContext(HttpRequestMessage request)
at MyCompany.Web.Http.HttpResponseBuilderTests.PrepareBuilder(String url)
at MyCompany.Web.Http.HttpResponseBuilderTests.HttpResponseBuilder_BuildResponse__when__success_get_with_no_rowversion__then__200OK_with_no_etag()
解决方案是巨大的。我已将所有 Json.NET 包更新为 7.x,并检查了所有配置文件中的所有绑定引用。
所有团队的开发 PC 在本地一切都很好。仅在 NUnit 运行器下的构建服务器上存在问题。
我认为System.Net.Http.Formatting 对版本 6.x 有硬性参考。就好像测试运行器没有注意配置中的绑定重定向。
我要开始戒掉 Json.NET,它变得比它的价值更麻烦,而且 VS 没有提供解决此类问题的帮助也无济于事。
感谢您的帮助。
卢克
Fusion 日志显示没有看到程序集绑定重定向,即使它在那里。同事已经检查过。
这很奇怪。
已删除测试项目的 app.config 中的所有其他重定向,并尝试仅使用 Json.NET 重定向。
未找到应用程序配置文件
在 Fusion 日志中,越来越近了!
【问题讨论】:
标签: .net json.net nunit teamcity