我尝试使用命令install-package newtonsoft.json
通过NuGet安装Json.Net。
我得到了一个错误,如下所示。我该如何解决此问题?
Install-Package Newtonsoft.Json
Installing 'Newtonsoft.Json 6.0.6'.
Successfully installed 'Newtonsoft.Json 6.0.6'.
Removing 'Newtonsoft.Json 6.0.3' from ReadJSON.
Successfully removed 'Newtonsoft.Json 6.0.3' from ReadJSON.
Adding 'Newtonsoft.Json 6.0.6' to ReadJSON.
Uninstalling 'Newtonsoft.Json 6.0.6'.
Successfully uninstalled 'Newtonsoft.Json 6.0.6'.
Install failed. Rolling back...
Install-Package : Could not install package 'Newtonsoft.Json 6.0.6'. You are trying to install this package into a project that
targets 'Silverlight,Version=v4.0,Profile=WindowsPhone71', but the package does not contain any assembly references or content files
that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Newtonsoft.Json
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
6.0版Json.Net中删除了对WindowsPhone7和Silverlight4的支持(源代码)。如果您仍然需要以WP7/SL4为目标,那么您将需要使用Json.Net v5.0.8。您可以在Package Manager控制台中使用以下命令来安装它:
Install-Package Newtonsoft.Json -Version 5.0.8