Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly Conflict in Newtonsoft.Json

We are getting an assembly conflict after we updated Newtonsoft.Json. I am having trouble understanding where the specific version that is referenced in the error is coming from. There is nothing in the web.config that points to a specific version.

System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=3.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)

Would GAC-ing the two versions of the assembly work to solve the issue?

like image 856
sestocker Avatar asked Dec 14 '12 13:12

sestocker


1 Answers

As @jammykam commented in marto's answer you can redirect the assembly. I have done this in the past with Newtonsoft and Sitecore without a problem. You can take a look at my Sitecore Content as Service code where I have it working.

You are specifically interested in these lines in the web.config file: https://github.com/HedgehogDevelopment/sitecore-content-service/blob/master/Sitecore/Web/Web.config#L3499

<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>
like image 161
Sean Kearney Avatar answered Oct 22 '22 01:10

Sean Kearney