xUnit System.IO.FileLoadException Newtonsoft.Json 6.0.0.0
My build configuration can restore and build my solution but when running tests it fails looking for Newtonsoft.Json version 6.0.0.0
I've turned logging onto diagnostic and can see that my redirects are working and version 11.0.0.2 is being used when building each project.
This project has two test classes, only one is failing (all tests in this class are failing as the constructor call new MoqMockingKernel() which is the line in the stack trace below).
Happy to provide more information as needed. It's an MSBuild 15.0 configuration.
These tests were previously running but a lot of work has been done on the project recently and I can't track down what would be causing this.
Here is the stack trace from the test:
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 System.Web.Http.GlobalConfiguration.<>c.<CreateConfiguration>b__11_0()
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at Ninject.Web.WebApi.WebApiModule.Load()
at Ninject.KernelBase.Load(IEnumerable`1 m)
at Ninject.Modules.ModuleLoader.LoadModules(IEnumerable`1 patterns)
at Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules)
at Ninject.MockingKernel.MockingKernel..ctor()
at Ninject.MockingKernel.Moq.MoqMockingKernel..ctor()
at XXX.YYY.Web.Administration.Test.Services.ImportExportConfigServiceTests..ctor(ITestOutputHelper output) in D:\TeamCity\buildAgent\work\d7229fa1accd239b\Source\Source\Web.Administration.UnitTests\Services\ImportExportConfigServiceTests.cs:line 30
Please sign in to leave a comment.
Hi,
I'm a bit lost here. This issue seems to clearly point at some dependency attempting to load the wrong version of the library. Besides caching issues (which you could clear the temp folders and run a clean checkout to end), the only other option is that your program is trying to do it on its own.
We do have some generic steps to try to troubleshoot this in case it works in your dev environment but fails on teamcity: https://www.jetbrains.com/help/teamcity/common-problems.html#CommonProblems-BuildworkslocallybutfailsormisbehavesinTeamCity