I made some changes to my project that required updating Newtonsoft to version 10.0.2. My project runs fine locally, but when I try to build it on my testing environment through Jenkins, the build is failing and the site is throwing a 500 error:
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)
When I ran nuget to install packages, changes to Newtonsoft.Json were made in three files: src/MySite.Library/packages.config, web/Website/packages.config, and web/Website/MySite.csproj:
packages.config:
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net45" />
csproj:
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
I tried modifying the web.config to see if that would fix the 500 error, since I noticed that it was still using the old version:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
I changed this to
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.2" />
</dependentAssembly>
Before I changed the web.config, the error said "Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0". When I changed the config to 10.0.2, it now says "Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0"