2

我用的NuGet安裝「微軟的ASP.NET Web API客戶端庫」以獲取在Windows中使用的最新裝配System.Net.Http Phone 7.1 XNA和Silverlight項目。它在我的WP7.1 XNA項目中安裝得很好,但不允許我將它安裝到WP7.1 Silverlight項目中。我甚至嘗試直接從程序包管理器控制檯將其安裝到新創建的WP7.1 Silverlight項目,並得到了這個錯誤響應:無法安裝System.Net.Http包到了Windows Phone 7.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 

是與WP7.1的Silverlight項目System.Net.Http兼容的,如果是這樣,我怎樣才能使它工作?

感謝

+0

WP HTTP方法都基於異步和其他HTTP方法未在WP支持同步。因此,建議使用WP SDK中的異步方法。 – nkchandra

+0

System.Net.Http支持異步通信。我不是在尋求關於使用這個程序集的可取性的意見 - 我只想知道它是否可以安裝到SP7.1 Silverlight項目中,如果是的話,如何去做。謝謝... –

+0

我在http://nuget.org/packages/System.Net.Http發現了這個說法:「傳統包,System.Net.Http現已包含在‘Microsoft.Net.Http’包」。 ,儘管我在嘗試將其安裝到WP7.1 Silverlight項目時遇到了類似的錯誤。 –

回答

6

丹·羅斯(在System.Net.Http NuGet包的擁有者)通過電子郵件迴應說:「System.Net.Http.dll未在XNA,電話或Silverlight在這一點上支持它。僅支持.NET 4(通過ASP.NET Web API),.NET 4.5以及Windows 8中的.NETCore Profile。「所以這是對這個問題的不幸答案。

2

,因爲這出現在谷歌1日公測包現在支持的Windows Phone 7.1的項目

安裝用戶包管理器控制檯

PM>安裝,包裝Microsoft.Net.Http - 預

Click here for project home page

+0

這對我來說也是一樣。 –

3

正如Dan指出的那樣,System.Net.Http NuGet包已被棄用,以Microsoft.Net.Http爲受益人。對於允許定位Windows Phone 7.1的後者we shipped an update

我們正在努力出貨穩定版本,但我們沒有時間未定。

相關問題