Upgrading NewtonSoft causes 404 error (0x80070002)

0

.Net 4.6.1 framework
I've Upgraded NewtonSoft in all my projects from 9.0.1 to 12.0.3.

Before the upgrade everything works fine - Now I got in my home page:

HTTP Error 404.0 - Not Found
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL https://www.example.com:443/home/index
Physical Path C:\path\to\home\index
Logon Method Anonymous
Logon User Anonymous

What could be the issue?

enter image description here

c#
json.net
asked on Stack Overflow Jul 16, 2020 by chenop

1 Answer

1

Ok, After I debug the global.asax I found there was an exception been thrown.

System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=9.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)
File name: 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.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)
File name: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

So I understand my web.config still looks for NewtonSoft 9.

Changing in the web.config from this:

<dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>

to this:

<dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>

Solved the issue for me.

answered on Stack Overflow Jul 16, 2020 by chenop

User contributions licensed under CC BY-SA 3.0