gpt4 book ai didi

c# - 无法添加对 'System.Net.Http' 的引用。请确保它在全局程序集缓存中

转载 作者:IT王子 更新时间:2023-10-29 04:19:18 25 4
gpt4 key购买 nike

我正在尝试将 Microsoft.AspNet.WebApi Nuget 包添加到 C# 类库项目中。 Here's the Project source code以备不时之需。

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

PM> install-package Microsoft.AspNet.WebApi ErrandBoy.Web.Common

我收到以下错误。

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

具体报错行如下。它似乎是它试图添加对 Adding 'Microsoft.AspNet.WebApi.Client 5.2.2'

的引用的地方
Failed to add reference to 'System.Net.Http'. Please make sure that it is 
in the Global Assembly Cache.

我以前从未遇到过这样的错误。我确实在这个 SO Overflow 问题上看到了类似的错误 => Error on installing ASP.NET Identity 2 Samples但是那个没有答案。

错误截图:

https://github.com/theShiva/ErrandBoy failed to add reference to system.net.http nuget package web api error

最佳答案

我刚刚遇到了同样的问题。我通过手动将 System.Net.Http 添加到引用中解决了这个问题。然后它提示其他人,但在手动将它们一一添加后,我能够使用 NuGet 安装包。

关于c# - 无法添加对 'System.Net.Http' 的引用。请确保它在全局程序集缓存中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27651342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com