After adding a reference (via Nuget or a direct reference) to another library from your .NET 4.0 project you get an exception similar to the following:
The primary reference “foo.dll” could not be resolved because it has an indirect dependency on the framework assembly “System.Runtime, Version=126.96.36.199, Culture=neutral, PublicKey Token=b03f5f7f11d50a3a” which could not be resolved in the currently targeted framework. “.NETFramework, Version=v4.0”. To resolve this problem, either remove the reference “XYZ.dll” or retarget your application to a framework version which contains “System.Runtime, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
The library you are referencing has a dependency on Microsoft.Bcl.Async, probably because it using Async and Await. The async functionality is baked into .NET 4.5 but is available in 4.0 if you use Microsoft.Bcl.Async.
While researching the error you’ll see a lot of instructions for adding assembly binding redirects. You may also try referencing the System.Runtime.dll that came with your dependency. Those may only fix part of the problem. I did plenty of searching and finally found the full solution here:
There is a known issue that causes MSBuild to think that the referencing library has taken a dependency on an assembly from a newer framework version. There is a fix included in Microsoft.Bcl.Build. The solutions is to simply install the Microsoft.Bcl.Async package directly into your project, it will include Microsoft.Bcl.Build.
In my case I was referencing a library that referenced a library that used Microsoft.Bcl.Async. The library that I referenced included references to the Microsoft.Bcl dlls but I had to add them to my project as well.