Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly Conflict with Newtonsoft.Json

Tags:

I need to load 2 versions of assembly Newtonsoft.Json version 4.0.8.0 and 4.5.0.0. My current config file :

<dependentAssembly>         <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />         <bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" /> </dependentAssembly> 

but it needs to be: old 4.0.8.0 and new 4.5.0.0

  <dependentAssembly>         <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />         <bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.5.0.0" />       </dependentAssembly> 

I installed Newtonsoft from Package Console - the latest version - but it gives me an error:

Error 80 Could not load file or assembly 'Newtonsoft.Json, Version=4.5.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)**

like image 786
Alex Avatar asked Oct 07 '13 13:10

Alex


People also ask

Is Newtonsoft JSON obsolete?

Yet Newtonsoft. Json was basically scrapped by Microsoft with the coming of . NET Core 3.0 in favor of its newer offering designed for better performance, System. Text.

Why we use Newtonsoft JSON DLL?

The Newtonsoft. JSON namespace provides classes that are used to implement the core services of the framework. It provides methods for converting between . NET types and JSON types.

Is Newtonsoft JSON included in .NET core?

Json library is included in the runtime for . NET Core 3.1 and later versions.


2 Answers

I got this problem today, I found the solution in this link.

Basically update the Newtonsoft.Json package. And register this assembly in the web.config

<dependentAssembly>     <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />     <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.8"/> </dependentAssembly> 
like image 124
nramirez Avatar answered Oct 25 '22 21:10

nramirez


I had the same problem after installing SignalR to my project. First I updated to the latest version of Newtonsoft.Json, and then I add the dependentAssembly to my web.config. But I had to put the value of 6.0.0.0 in the new Version, even if in my packages I have version 6.0.8 declared.

<dependentAssembly>   <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>   <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="6.0.0.0"/> </dependentAssembly> 
like image 31
Ralf D'hooge Avatar answered Oct 25 '22 23:10

Ralf D'hooge