JWT is coupled with json 9.0.0 and not higher
Hello Guys ,
I have installed JWT 4.0.0 version and json version 12.0.1 , but while validating tokens i am getting error saying it needs json version 9.0.0 even though i have higher version (12.0.1)
Please let me know for the solutions
Hi, do you have assembly binding redirects in your Web/App.config in place? See https://stackoverflow.com/a/24461105/41956
yes i do have like below:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>`
What exception you're getting? It should work if that's what you have.
this is the error
Could not load file or assembly 'Newtonsoft.Json, Version=9.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)
Odd. Can you describe the project structure? Is this a web app, console app? .NET Framework or .NET Core?
I'd suggest to create a simple project without all the complexity of real project and try to reproduce the issue there
Have you figured this out? Can I close?
I have added the test project without any other Dependency it works fine , hence this can be closed.
I will have a look into the problem and provide the solution
@IAm-Naveen have you figured it out? I have the same issue. Class library, loaded in winforms app. Both target FW is 4.6.2 Newtonsoft.Json version = 12.0.0.0
Exception:
Could not load file or assembly 'Newtonsoft.Json, Version=9.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)
w JWT.Serializers.JsonNetSerializer..ctor()
w AllegroClient.AllegroRESTClient.GetCurrentAccountID() w H:\C#\SubSync\BrokerDll\Broker\Allegro\AllegroClient\AllegroRESTClient.cs:wiersz 234
w AllegroClient.AllegroRESTClient.GetCurrentAccountLogin() w H:\C#\SubSync\BrokerDll\Broker\Allegro\AllegroClient\AllegroRESTClient.cs:wiersz 253
w AllegroClient.Config.ConnectionSettings.buttonRenewTokens_Click(Object sender, EventArgs ea) w H:\C#\SubSync\BrokerDll\Broker\Allegro\Config\ConnectionSettings.cs:wiersz 134
@rtnet-pl I had a weird solution , When i download JWT package it didn't download json at all so what i did is to explicitly download json package with version 12. Also can you verify if all your class libraries have same version ?
NuGet.exe will download and install all dependencies until is instructed to do otherwise. The package's nuspec states Newtonsoft.Json version 9.0.1 or higher. This version was selected as something not to old but not too new either (to allow clients with all old dependencies to consume the package as well).
OK, i'm not that good in all the nuget dependencies stuff.
I ended up by downloading JWT source, downloading all available nuget packages updates, and building my own lib.
There's one thing i found. JWT for .NET 4.6 references Newtonsoft.Json.dll, but its target framework is 4.7.2. So if the host assembly target fw version is lower (4.6.2 in my case), it wont be loaded.

Target framework doesn't matter when NuGet restores packages with all its dependencies recursively. Can you again state what's the problem? I can guarantee you there are no issues from the JWT package side. But I can try to help to resolve an issue at yours.
I can't tell if this was closed or not but I'm getting same error (as of 2/19/20). I have Newtonsoft.Json 12.0.3 installed, have tried 9.0.1, 10.0.1 and also letting JWT install Newtonsoft.Json for me (as a dependency) but in all cases I get the below error:
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. at JWT.Serializers.JsonNetSerializer..ctor() at JWT.Builder.JwtBuilder..ctor()
Is there a solution outside grabbing the source and fussing with myself?
Hi Chris, do you have assembly binding redirects in place? Or you have an SDK-based project? Can you attach a zip with small repro or create a public repo with such?
@abatishchev Sorry my project is kind of large / hard to repro. I tried grabbing this repo/source FWIW but got stuck trying to install dev packs and building the solution so I gave up. For now I had to go with jose-jwt but if I have time at some point I'll circle back and report any new findings or a sample project.
Ok, then tell me just this:
do you have assembly binding redirects in place? Or you have an SDK-based project?