I was working with an ASP.NET MVC and ASP.NET Web API solution recently and each time I built the solution, I would get the following exception:
Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies
I checked in the assembly directory and sure enough the assembly version of Newtonsoft.Json that was being placed into the bin directory was an older version of the assembly!
I then decided to look at the project assembly references to see where that version was coming from and this is what I found:
Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies
I checked in the assembly directory and sure enough the assembly version of Newtonsoft.Json that was being placed into the bin directory was an older version of the assembly!
I then decided to look at the project assembly references to see where that version was coming from and this is what I found:
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
Well, after doing a bit of searching on the Internet, I discovered that this was the best solution to resolve these invalid project references across the solution.
From the NuGet Package Manager Console, run the following command:
Update-Package –reinstall Newtonsoft.Json
After doing that, I re-checked all of my project assembly references and this is what I now found:
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
That was all that was needed to take care of this annoying problem with mismatched assembly versions!!
No comments:
Post a Comment