Have you ever tried running an EPiServer MVC website with the latest version of the ASP.NET MVC Framework and latest versions of all the nuget packages? Well, it won’t work very well…
Unfortunately EPiServers EPiServer.Framework nuget package only supports Newtonsoft.Json version >= 5.0.8 and <= 6.0 (which is the same thing as saying we only support 5.0.8 as there are no other releases in the span).
This means that we will have to downgrade our Newtonsoft.Json package to be able to install the EPiServer.Framework nuget package. Fortunately this is quite simple and WebGrease (another package used by the Microsoft ASP.NET Web Optimization package) only requires NewtonSoft.Json >= 5.0.4 so thus far this shouldn’t be a problem.
Go to your Package Manager Console and type the command:
Update-Package Newtonsoft.Json -Version 5.0.8
This will downgrade your Json.Net installation to version 5.0.8. Now we can carry on installing the EPiServer.Framework nuget package without issue.
However, you might still run into this error:
Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
Turns out that the assembly redirect in web.config is still looking for the 6.0.x version of Newtonsoft.Json. To fix this do not change the version to 5.0.8 and hope for the best, the version number of < 6.0 of Json.Net had the version 184.108.40.206 so changing to that version should work. However, simply removing the assembly redirect is a simpler and more direct solution. It serves no purpose anyway as we know that the version we have installed is the one we want to use so we simply put the assembly redirect tag out of its misery.