Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type 'JsonConvert' exists in both 'Newtonsoft.Json ver 9 and 10

Tags:

c#

json.net

I am constantly plagues by issues where Newtonsoft.Json seems to be available in multiple versions within my project. The problem is that it is not. I have 10 installed in the project, and that's the only DLL that's in place. The GAG does not have the dll, and the web.config seems correct.

The type 'JsonConvert' exists in both 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' and 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'    

Has anyone else seen this? Is there a way to specify the version to use at code level, or within the web.config?

like image 714
Alex T Avatar asked Nov 28 '22 00:11

Alex T


1 Answers

This seems to be due to multiple invisible references to the Newtonsoft.Json DLL

  1. Right click on your project and select Unload Project.
  2. Now right click again and select Edit MyProject.csproj (or whatever your project is called)
  3. Search for Newtonsoft.Json within this file.
  4. If you find multiple Reference elements with different versions, delete all but the newest version
  5. Save the file
  6. Right click on your project again and select Reload Project

The errors should be gone.

like image 115
AaronHolland Avatar answered Dec 10 '22 19:12

AaronHolland