C# 未能添加对';的引用;System.Net.Http';。请确保它位于全局程序集缓存中

C# 未能添加对';的引用;System.Net.Http';。请确保它位于全局程序集缓存中,c#,asp.net-web-api,nuget,C#,Asp.net Web Api,Nuget,我正在尝试将Microsoft.AspNet.WebApiNuget包添加到C#类库项目中。万一你需要的话 当我在Visual Studio 2013的Nuget Package Manager控制台中执行以下命令时(其中包含最新的.NET 4.5) 我得到以下错误 PM> install-package Microsoft.AspNet.WebApi ErrandBoy.Web.Common Attempting to resolve dependency 'Microsoft.AspN

我正在尝试将
Microsoft.AspNet.WebApi
Nuget包添加到C#类库项目中。万一你需要的话

当我在Visual Studio 2013的Nuget Package Manager控制台中执行以下命令时(其中包含最新的.NET 4.5)

我得到以下错误

PM> install-package Microsoft.AspNet.WebApi ErrandBoy.Web.Common
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.WebHost (≥ 5.2.2 && < 5.3.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Core (≥ 5.2.2 && < 5.3.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Client (≥ 5.2.2)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 6.0.4)'.
'Microsoft.AspNet.WebApi 5.2.2' already installed.
Adding 'Newtonsoft.Json 6.0.4' to ErrandBoy.Web.Common.
Successfully added 'Newtonsoft.Json 6.0.4' to ErrandBoy.Web.Common.
Adding 'Microsoft.AspNet.WebApi.Client 5.2.2' to ErrandBoy.Web.Common.
install-package : Failed to add reference to 'System.Net.Http'. Please make sure that it is in the Global Assembly Cache.
At line:1 char:1
+ install-package Microsoft.AspNet.WebApi ErrandBoy.Web.Common
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
我以前从未犯过这样的错误。我确实在这个问题上看到了类似的错误,但这个问题没有答案

错误屏幕截图:
我也有同样的问题。我通过手动将
System.Net.Http
添加到引用中解决了这个问题。然后它抱怨其他人,但是在手动一个接一个地添加他们之后,我能够用NuGet安装包。

我也遇到了同样的问题。我只是关闭了我的VisualStudio,然后重新启动它。此后,安装包时没有出现任何错误。

我只是通过在项目设置中将.Net framework版本更改为4.6.1解决了这个问题。然后我成功地安装了所有组件。

从package manager控制台进行了安装,成功了。

您是否安装了所需的.NET版本?是的。它位于Windows 8.1 ENT VM上,具有VS 2013和4.5之前的所有.Net版本。类库的目标框架是什么?查看NuGet源代码,基础异常作为InnerException添加到另一个异常,因此不会显示实际的错误消息。您应该能够通过在软件包管理器控制台中运行类似于
$error[0]的操作来获取基本错误。Exception.ToString()
。存在相同的问题,但我运行了几次install Package命令(带有不同的错误消息),最后它安装正确。基本错误是,完成此操作所需的数据尚不可用。(HRESULT的例外:0x800000A)奇怪但真实
PM> install-package Microsoft.AspNet.WebApi ErrandBoy.Web.Common
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.WebHost (≥ 5.2.2 && < 5.3.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Core (≥ 5.2.2 && < 5.3.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Client (≥ 5.2.2)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 6.0.4)'.
'Microsoft.AspNet.WebApi 5.2.2' already installed.
Adding 'Newtonsoft.Json 6.0.4' to ErrandBoy.Web.Common.
Successfully added 'Newtonsoft.Json 6.0.4' to ErrandBoy.Web.Common.
Adding 'Microsoft.AspNet.WebApi.Client 5.2.2' to ErrandBoy.Web.Common.
install-package : Failed to add reference to 'System.Net.Http'. Please make sure that it is in the Global Assembly Cache.
At line:1 char:1
+ install-package Microsoft.AspNet.WebApi ErrandBoy.Web.Common
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
Failed to add reference to 'System.Net.Http'. Please make sure that it is 
in the Global Assembly Cache.