我使用Nuget安装“Microsoft ASP.NET Web API客户端库”以获取最新的System.Net.Http程序集,以便在Windows Phone 7.1 XNA和Silverlight项目中使用。它在我的WP7.1 XNA项目中安装得很好,但是不允许我将它安装到WP7.1 Silverlight项目中。我甚至尝试将它从Package Manager Console直接安装到新创建的WP7.1 Silverlight项目中,并获得了此错误响应:
PM> Install-Package System.Net.Http
Attempting to resolve dependency 'Microsoft.Net.Http (≥ 2.0.20710.0 && < 2.1)'.
You are downloading Microsoft.Net.Http from Microsoft, the license agreement to which is available at http://www.microsoft.com/web/webpi/eula/MVC_4_eula_ENU.htm. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Microsoft.Net.Http 2.0.20710.0'.
You are downloading System.Net.Http from Microsoft, the license agreement to which is available at http://www.microsoft.com/web/webpi/eula/MVC_4_eula_ENU.htm. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'System.Net.Http 2.0.20710.0'.
Successfully uninstalled 'Microsoft.Net.Http 2.0.20710.0'.
Install failed. Rolling back...
Install-Package : Could not install package 'Microsoft.Net.Http 2.0.20710.0'. 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 that are compatible with that framework. For more information, contact the package author.
At line:1 char:16
+ Install-Package <<<< System.Net.Http
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
System.Net.Http是否与WP7.1 Silverlight项目兼容,如果是这样,我怎样才能使它工作?
由于
答案 0 :(得分:6)
Dan Roth(System.Net.Http Nuget软件包的所有者)通过电子邮件回复:“此时,System.Net.Http.dll不支持XNA,Phone或Silverlight。它只支持.NET 4(通过ASP.NET Web API),.NET 4.5。和Windows 8中的.NETCore配置文件。“所以这是这个问题的不幸答案。
答案 1 :(得分:3)
正如Dan所指出的,System.Net.Http NuGet包已被弃用,而不是Microsoft.Net.Http。对于允许定位Windows Phone 7.1的后者we shipped an update。
我们正在努力发布稳定版本,但我们还没有约会。
答案 2 :(得分:2)
因为这在google上排名第一,beta套件现在支持windows phone 7.1项目
安装用户包管理器控制台
PM&GT;安装包Microsoft.Net.Http -Pre