Reputation: 765
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?
Upvotes: 9
Views: 11582
Reputation: 1675
This seems to be due to multiple invisible references to the Newtonsoft.Json DLL
The errors should be gone.
Upvotes: 30
Reputation: 324
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.
Upvotes: 10
Reputation: 156978
You should force to load only one assembly, I suggest to load the latest one. You can check if all referenced assemblies use that version. If not, you have to add this to your web.config
file:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
This will force to use version 10 of Newtonsoft.Json
. Make sure to remove version 9 from the bin
folder.
Upvotes: 3