Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to add Microsoft.AspNet.WebApi Nuget Package to a C# Class Library Project. Here's the Project source code in case you need it.

When I execute the following command in the Nuget Package Manager Console in Visual Studio 2013 (it has latest .NET 4.5 in it)

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

I get the following Error.

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 

The specific error line is the following. It seems to be where it's trying to add reference to 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. 

I've never gotten such an error before. I did see a similar error on this SO Overflow question => Error on installing ASP.NET Identity 2 Samples but that one has no answer.

Error Screenshot:

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

like image 957
Shiva Avatar asked Dec 25 '14 22:12

Shiva


1 Answers

I just had the same issue. I solved it by manually adding System.Net.Http to the references. Then it complained about others, but after adding them manually one by one I was able to install the package with NuGet.

like image 88
Adam Szabo Avatar answered Sep 29 '22 15:09

Adam Szabo