I have 2 solutions in one project. One of the solutions is a unit test project, they both have the same Newtonsoft.Json package version.
This is the location with the csproj file where the package is installed:
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
If I change the version to 12.0.3, the solution isnt able to find Newtonsoft class anymore.
Full error message.
System.IO.FileLoadException: 'Could not load file or assembly 'Newtonsoft.Json, Version=12.0.3.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)'
My packages.config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Core" version="4.5.2" targetFramework="net461" />
<package id="HtmlAgilityPack" version="1.7.4" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="RestSharp" version="106.6.10" targetFramework="net461" />
<package id="ScrapySharp" version="3.0.0" targetFramework="net461" />
<package id="System.Runtime.Caching" version="4.5.0" targetFramework="net461" />
</packages>
I tried to reinstall the pack and clean, rebuild and close and open my visual studio. It gives the same error. I dont understand what VS2019 tries to do behind the scenes, but it doesnt find the dll.
This is what I get after the re-install the package,
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
It keeps adding this. Why hte version is 12.0.0.0
I have used AsmSpy.exe (available in NuGet) to analyze this type of problem. It looks at all the libraries and their dependencies and reports on inconsistencies.
Very common problem with json newtonsoft for more than 1 projects, just update the package in your unit test project. Sometimes the old version overwrite the DLL of another project.
User contributions licensed under CC BY-SA 3.0