Could not load file or assembly 'Newtonsoft.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match

Jul 27, 2011 at 10:14 PM

hey guys,

 

i love the newtonsoft library, but i'm getting an error. the weird thing is that i don't get the error when i run my website on my localhost, but when i copy all of my files over to a server that is running IIS i get this error:

 

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

everything else on my website seems to be working correctly. i checked the /bin folder for the web application and the Newtonsoft.Json.dll is there and when i right click the file and check the properties, the File Version is 4.0.2.13623 and this is the same as the file version that i have for the file on my localhost. here is an image for what i see in visual studios:

http://i.imgur.com/UpWvW.jpg

 

does anyone have any ideas what could be wrong?

Jul 28, 2011 at 11:27 PM

i figured out my problem.  basically, there were different assemblies that were trying to reference different versions of Newtonsoft.Json.dll, and since Copy Local was set to True, only one version of the referenced assembly was copied into the /bin folder when i published my website project. here is how the references looked (an arrow points at the assembly it is referencing):

my web app project
   |
   |------> Newtonsoft.Json.dll (version 4.0.2.0.13623)
   |------->Facebook.dll
                   |
                   |-----------> Newtonsoft.Json.dll (version 4.0.0.0)

you will notice that two different versions of Newtonsoft.Json.dll are being referenced, but only one version is inside the application's /bin folder. the reason i don't hit this error in my development environment is because inside my development environment Facebook.dll and version 4.0.0.0 of Newtonsoft.dll are inside:
c: \Trunk\mywebapp\importedbin\release\Facebook.dll

while Newtonsoft.Json.dll version 4.0.2.0 is inside c:\Trunk\mywebapp\packages\Newtonsoft.Json.4.0.2\lib\net40\

 

my options to solve ths problem are:

1.) add both versions of the dll to the GAC

2.) update my web app project to use the older Newtonsoft.Json.dll (v. 4.0.0.0)

3.) download the source and compile Facebook.dll to use the newer version of Newtonsoft.Json.dll

Sep 7, 2011 at 8:05 PM

Hi there, where can I get Newtonsoft.Json.dll (version 4.0.0.0) as this version already overwritten by version 4.0.2.0.13623. I can't find this DLL in Facebook SDK too.

Thanks.

Dec 5, 2011 at 7:17 PM
Edited Dec 6, 2011 at 6:07 AM

Hi,

I have following issue

1. I have assembly(for which I do not have source, just dll) that references newtonsoft.json 3.0.0.0 without public key token or =null

2. I want to use newtonsoft.json 4.0.4.0 with public key token from nuget

as both newtonsoft.json have different public key tokens, I cant do none of following:

 

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

 

any suggestions what can i do other than use reflector?

I would really prefer configuration solution, if there exists one.