如何在.NET 4.0项目中使用HttpClient和System.Net.Http.dll?

时间:2013-08-19 12:56:01

标签: c# dotnet-httpclient base-class-library

我在我的解决方案中使用了HttpClient。 该解决方案针对的是.NET 4.0,因为WinXP-Customers无法安装.NET 4.5。 在我检查了我的更改后,TFS报告未找到System.Net.dll。 我发现了什么问题 - 该DLL仅适用于.NET 4.5。否则你应该使用Nuget包用于HttpClient。后者具有Microsoft.Bcl.Async包的依赖性。我无法使用我的NuGet包管理器(最新版本2.6)安装它:

PM> Install-Package Microsoft.Net.Http
Attempting to resolve dependency 'Microsoft.Bcl (≥ 1.1.3)'.
Attempting to resolve dependency 'Microsoft.Bcl.Build (≥ 1.0.4)'.
Installing 'Microsoft.Bcl.Build 1.0.8'.
You are downloading Microsoft.Bcl.Build from Microsoft, the license agreement to which 
is available at http://go.microsoft.com/fwlink/?LinkID=296407. 
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:

Install failed. Rolling back...
Install-Package : This BackgroundWorker is currently busy and cannot run multiple 
tasks      concurrently.
At line:1 char:16
+ Install-Package <<<<  Microsoft.Net.Http
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

什么会导致这样的问题?我如何安装包?

  • VS2012 Update 3
  • NuGet 2.6.40627.9000
  • 解决方案目标:.NET 4.0

更新 已经卸载了一些VS扩展,尤其是:

关闭所有与TFS相关的工具窗口, 然后重新启动VS,它的工作原理。

但是我会更多地了解错误消息的含义和原因。

0 个答案:

没有答案