. Advertisement .
. Advertisement .
Hi developer experts,
I have a small but frustrating use case, and so far, I couldn’t get my head around this problem & ideal solution. I am running my command and facing one problem with the could not load file or assembly newtonsoft json.
Below is the command I used:
<dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-22.214.171.124" newVersion="126.96.36.199" /> </dependentAssembly>
When I run it, I get the following error:
System.IO.FileLoadException : Could not load file or assembly 'Newtonsoft.Json, Version=188.8.131.52, 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)
I am looking forward to gaining some knowledge from all experts.
Thank you, guys!
The cause: The error message claims that Newtonsoft version 184.108.40.206, Newtonsoft.Json is currently at version 220.127.116.11, hence the redirect should be from 4.5 to 6.0, not vice versa. not the other way around.
The solution: You can fix this error by adding the following binding redirect to your .config file:
Update-Package –reinstall Newtonsoft.Jsonis a
Update-Package –reinstall Newtonsoft.Json-specific option in the package manager console.
I posted this originally as a comment, but @OwenBlacker suggested that I just post it here:
If you get an error still after this, I deleted Json.Net’s
.config. If it isn’t there, you can reinstall it. Otherwise, it will be deleted. This manual step is necessary until there is an automatic solution in the package.
Please note: Before you do this, please read the comments.
Rene’s comment in BE AWAREN states that the command in the answer will reinstall your package in all projects in your solution. If you are using the Newtonsoft.Json package for multiple projects, and possibly use different versions of the package, the above command may have unwelcome consequences.