Web API project won't run when its deployed - Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0

Viewed 9947

I keep getting this error when I deploy my MVC 5 WEB API project:

Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

I have followed this and re-install the NuGet package "Update-Package Newtonsoft.Json -Reinstall" but it didn't work.

Does anyone have any idea here as to what could be going wrong?

5 Answers

Have you tried putting an assembly redirect in your web config to make sure your application is looking for the correct version:

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

Manage Nuget packages for the entire solution, not just the project. You should see multiple versions of Newtonsoft.Json there. Pick the lowest version and then choose Manage. Uncheck all the selected checkboxes and confirm. After it has been successfully removed, repeat the process for any other lesser versions. When all you have left is one, latest, version of the package, click Manage on this one and check any projects where it's missing. Once it's done installing, you'll be good to go.

Related