Search code examples
c#.netnugetassemblyversions

Referenced Nuget package has errors finding system types


I have several strange errors after using NuGet to add a third party library to a project. The project targets .NET 4.5.2. The errors I get complain of standard system types not being of the correct version e.g.

CS0012: The type 'System.Collections.Generic.IEnumerable`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

I have cleaned the project folder, deleted the bin folder, reinstalled the NuGet package and readded the reference to no avail.

The library is Remotion.Linq

According to the Registry the following .NET versions are installed on the machine

v2.0.50727 2.0.50727.4927 SP2

v3.0 3.0.30729.4926 SP2

v3.5 3.5.30729.4926 SP1

v4
Client 4.6.01038 Full 4.6.01038 v4.0
Client 4.0.0.0

Does anyone know what is happening here?


Solution

  • This turned out to be a misleading error. The library was built against .NET 4.5.2 but I had .NET 4.5.1 installed. Microsoft explain this in a KB article (KB2971005) but you really need to know what the issue is to easily find the article. I somehow stumbled across it after a lot of searching.

    The resolution is to install the updated version of the Microsoft .NET Framework 4.5.2 Developer Pack.