23

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)**

LinkedListT
  • 681
  • 8
  • 24
Alex
  • 8,908
  • 28
  • 103
  • 157
  • 1
    I checked the JSON.net NuGet release information and I am not able to find the release 4.5.0.0 http://www.nuget.org/packages/newtonsoft.json/ Moreover if you already have the latest version of the library what is your need of using the older version? – Manvik Oct 07 '13 at 14:05
  • 9
    Why do I remember everything being so much easier before nuget? – Ronnie Overby May 28 '14 at 18:15

2 Answers2

39

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>
Community
  • 1
  • 1
nramirez
  • 5,230
  • 2
  • 23
  • 39
  • where did you get the publicKeyToken? – Lay González Apr 03 '14 at 05:39
  • 1
    When I tried to build my app, I got the publicKeyToken in the error list console so I copied it, but this is another way to get it http://stackoverflow.com/questions/1710935/how-do-i-find-the-publickeytoken-for-a-particular-dll If you have others references in your web.config, you may notice that they are equal, so you can copy the token from another assembly. – nramirez Apr 03 '14 at 14:48
  • This was kind of messy but I eventually got it working. First I updated my projects from Newtonsoft 9.x to 12.0.2. No luck. Then I went down back to 9.x and restarted VS. No go. Then I went from 9.x to 12.0.2 again. No go. Then I went from 12.0.2 to 12.0.1 and then it worked. /eyeroll. Least it's working now. – Christopher Oct 29 '19 at 16:39
8

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>
Ralf D'hooge
  • 262
  • 3
  • 7