Install-Package : Failed to add reference to 'System.Runtime'

Tomas Aschan picture Tomas Aschan · Jul 20, 2015 · Viewed 33.7k times · Source

I'm trying to install the Autofac nuget package in my project using the command

Install-Package -Prerelease Autofac

but it fails with the error

Install-Package : Failed to add reference to 'System.Runtime'. Please make sure that it is in the Global Assembly Cache.

I've tried re-installing .NET Framework 4.5.2 (which is the version my project targets) but got the message ".NET Framework 4.5.2 is already installed". However, searching C:\Windows\assembly\ for System.Runtime.dll doesn't find any exact matches (although there are a few instances of System.Runtime.ni.dll, which (seem to indicate) that they are really the same assembly...).

What can I do about this?

project config

Update: apparently I was confused about the location of the GAC. Amy enlightened me, and searching in C:\Windows\Microsoft.NET\assembly instead I do find System.Runtime.dll. Why doesn't Visual Studio?

Answer

Roboblob picture Roboblob · Jul 13, 2016

I had the same problem.

Found the solution here: https://github.com/aspnet/WebHooks/issues/18

To fix it, I added <Reference Include="System.Runtime"/> to the .csproj
file for the project, rebuilt it and it worked.