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

Viewed 5981

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?

3 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.

try install previous version of newtonsoft.json

in my circumstance, I updated newtonsoft to 11.0.2 from 6. Compiling gave this error message that include ver 6 and 11. I tried uninstall, but i did not, cause of dependencies. but I used this command and I succeded to downgrade. Install-Package Newtonsoft.Json -Version 11.0.1

and this error gone.

Related