0

I've been stuck with this bug after merging two branches together. The solution builds with no issues, but as soon as I call any function that uses Newtonsoft.Json I get the following exception at runtime:

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

I've looked around and have tried:

  • Re-installing the nuget package on the affected project
  • Re-installing the nuget package on all projects running Newtonsoft.Json
  • Updating all projects in the solution to be the same version of Newtonsoft.Json, then cleaning and rebuilding the solution
  • Digging through .csproj files to find Newtonsoft references and manually updating them to the same version.

When I manually copy and paste the 6.0.0.0 dll into the debug folder I get no issues, however as soon as I clean/ rebuild Visual Studio puts the wrong dll version into the folder again. Even after updating the Nuget package in the affected project to the latest version of Newtonsoft.Json the error still states that it is looking for version 6.0.0.0 rather than 12.0.0.0.

Am I missing something? Any help would be appreciated.

EDIT:

Using .net Framework 4.7

Just to clarify: when I say "wrong dll" I meant it puts the dll that I want it to use in the bin folder (12.0.0.0), but the program see's it as the wrong version, expecting version 6.0.0.0.

German Quinteros
  • 1,870
  • 9
  • 33
SomeGuy
  • 1
  • 2
  • Is there anything that need update? You're using .net core or what? – Mohamad Mousheimish Feb 24 '20 at 15:21
  • 1
    This link might be of help to you: https://stackoverflow.com/questions/22507189/could-not-load-file-or-assembly-newtonsoft-json-version-4-5-0-0-culture-neutr – Cooper1810 Feb 24 '20 at 15:22
  • @Cooper1810 has the right answer. However, in your case, you are going to want to point at version 12.0.0.0 – Flydog57 Feb 24 '20 at 15:25
  • Just edited the post to clarify some info. – SomeGuy Feb 24 '20 at 15:40
  • @Cooper1810 Unfortunately I've tried the solutions posted there with no success. My project has no app.config/ web.config to update the values the top answer suggests if the reinstall does not work – SomeGuy Feb 24 '20 at 15:51
  • hi @SomeGuy, is there a Console Application on your solution? – Pedro Coelho Feb 24 '20 at 16:16
  • @PedroCoelho Afraid not, the project in question is a library which is loaded into some other projects – SomeGuy Feb 25 '20 at 07:56
  • Alright, believe the issue is being caused by Microsoft.AspNet.WebApi.Client. After uninstalling Newtonsoft.Json I found I was still able to build. The 12.0.0.0 version of NewtonSoft.Json was still added to the output folder but the same issue occurred when PostAsJsonAsync was called – SomeGuy Feb 25 '20 at 10:37
  • Undid the merge, updated newtonsoft.json in the merging branch, tested it, worked fine with 12.0.0.0, re-did the merge... same error... I'm out of ideas – SomeGuy Feb 26 '20 at 08:40

1 Answers1

0

Was finally able to get it working. Ditched 12.0.0.0 completely, does not seem that there is a way to get Microsoft.AspNet.WebApi.Client working with any version beyond 6.0.0.0

SomeGuy
  • 1
  • 2