Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies

I am using Visual Studio 2017 and am trying to create a .Net Standard 1.5 library and use it in a .Net 4.6.2 nUnit test project.

I am getting the following error...

Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

I have tried the following:

  1. Reference Std library as project reference. Error: gives me the previous error.
  2. Create a NuGet pkg for my Std library and reference that. Error: The type is System.String, expecting System.String. This is because System.Runtime ended up getting referenced by the project and it has definitions for all the standard types.
  3. Reference NuGet pkg NetStandard.Library. Error: give me the same error as # ("The type is System.String, expecting System.String"). NOTE: Before I did this, I cleared ALL NuGet packages from the project and then added just the nUnit and NetStandard.Library packages (which installed 45 other packages).

Is this a bug? Is there a work-around? Any help is appreciated.


I had the same problem and no suggested solutions that I found worked. My solution for this issue was: Check App.config and packages.config to see if the versions match.

Originally my app.config contained:

<dependentAssembly>
  <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>

But the packages.config contained:

<package id="System.Runtime" version="4.3.0" targetFramework="net461" requireReinstallation="true" />

I modified the app.config entry to match packages.config for the newVersion:

<dependentAssembly>
  <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.3.0" />
</dependentAssembly>

After the change, the issue was resolved.


I encounter this issue recently and I tried many things mentioned in this thread and others. I added package reference for "System.Runtime" by nuget package manager, fixed the binding redicts in app.config, and make sure that app.config and package.config have the same version for the assembly. However, the problem persisted.

Finally, I removed the <dependentAssembly> tag for the assembly and the problem dissappeared. So, try removing the following in your app.config.

<dependentAssembly>
    <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.1.0" />
</dependentAssembly>

Edit: After I update .NET framework to 4.7.2, the problem resurfaced. I tried the above trick but it didn't work. After wasting many hours, I realized the problem is occurring because of an old System.Linq reference in app.config. Therefore, either remove or update all Linq references also to get rid of this problem.


This issue happens when you reference a .NET Standard project from a .NET 4.x project: none of the .NET Standard project's nuget package references are brought in as dependencies.

To fix this, you need to ensure your .NET 4.x csproj file is pointing to current build tools (at least 14):

<Project ToolsVersion="15.0">...

The below should no longer be needed, it was fixed around VS 15.3:

There was a known bug in VS2017, specifically in NuGet 4.0.

To work around the bug, you'll need to open up the .csproj file for your .NET 4.x project and add this snippet:

<ItemGroup>
  <PackageReference Include="Legacy2CPSWorkaround" Version="1.0.0">
    <PrivateAssets>All</PrivateAssets>
  </PackageReference>
</ItemGroup>

NuGet 4.x brings with it the "package reference" -- no more packages.config -- but the old 4.x pipeline was not fully updated at the time of VS2017's launch. The above snippet seems to "wake up" the build system to correctly include package references from dependencies.