To avoid the issue described here:
Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib
I'm trying to build my project to target .net 4.0 instead of 4.5 (in Visual Studio 2013), but I get the following errors:
-
The type or namespace name 'Newtonsoft' could not be found (are you
missing a using directive or an assembly reference?)The primary reference "Newtonsoft.Json" could not be resolved because
it was built against the ".NETFramework,Version=v4.5" framework. This
is a higher version than the currently targeted framework ".NETFramework,Version=v4.0".
So I would like to install a version of json.net that is compatible with .net 4.0. I see that the downloaded NuGet package contains a lib/4.0 directory in addition to lib/4.5, but I can't figure out how to get the package manager to use this instead of the 4.5 version.
How can I get my project solution to buikd using the version of json.net compatible with .net 4.0 instead of the one that only works with .net 4.5?
Best Answer
Run
update-package -reinstall
from the package manager console.