jws305
jws305

Reputation: 115

Why is .Net trying to load the wrong version of Newtonsoft.Json?

In my project I have the following packages installed:

When the program runs, it throws an exception

System.IO.FileLoadException

Could not load file or assembly 'Newtonsoft.Json, Version=10.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)
   at JWT.Serializers.JsonNetSerializer.Serialize(Object obj)
   at JWT.JwtEncoder.Encode(IDictionary`2 extraHeaders, Object payload, Byte[] key)
   ...

Why is .Net attempting to load this version of Newtonsoft.Json. JWT requires v6.0.4 or greater which I have satisfied. Both of these packages were installed and working before Newtonsoft.Json even had a v10. How does the runtime even know a v10 exists?

I solved the immediate problem by adding a binding redirect back down to v9 but I would like to find the root of the problem.

I ran update-package Newtonsoft.Json -reinstall and looked at all the pending changes to see if any of the projects had a reference to v10 but I couldn't find anything.

Upvotes: 0

Views: 840

Answers (1)

Max Zuber
Max Zuber

Reputation: 19

Check the .*csproj file by Right click -> unload project -> Right click -> edit .*csproj in visual studio or open it with any text editor.

Some times its save reference to the old version of the package

Upvotes: 1

Related Questions