2

我使用 Nuget 安装“Microsoft ASP.NET Web API 客户端库”来获取最新的 System.Net.Http 程序集,用于 Windows Phone 7.1 XNA 和 Silverlight 项目。它可以很好地安装到我的 WP7.1 XNA 项目中,但不允许我将它安装到 WP7.1 Silverlight 项目中。我什至尝试将它直接从包管理器控制台安装到新创建的 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 项目兼容,如果是,我怎样才能让它工作?

谢谢

4

3 回答 3

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 配置文件。” 这就是这个问题的不幸答案。

于 2012-09-21T16:55:01.967 回答
3

正如 Dan 所指出的, System.Net.Http NuGet 包已被弃用,取而代之的是Microsoft.Net.Http。对于后者,我们发布了一个允许以 Windows Phone 7.1 为目标的更新。

我们正在努力发布一个稳定的版本,但我们还没有确定日期。

于 2013-04-27T16:26:47.463 回答
2

由于这在 google 上排名第一,因此 beta 包现在支持 windows phone 7.1 项目

安装用户包管理器控制台

PM> Install-Package Microsoft.Net.Http -Pre

点击这里进入项目主页

于 2013-02-27T01:42:31.187 回答