.NET Standard 2.0 cannot be referenced in .NET Framework 2.0

mjb picture mjb · Jan 12, 2018 · Viewed 7.7k times · Source

I received an error:

'c:......\xxxx.csproj' targets '.NETStandard,Version=v2.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v2.0'. WindowsFormsApp1

How to resolve?

Answer

Martin Zikmund picture Martin Zikmund · Jan 12, 2018

Unfortunately you cannot reference a .NET Standard library in .NET 2.0 project. The reason is that .NET 2.0 is missing many key API and hence cannot implement the .NET Standard 2.0 contract. If you cannot modify the source of the .NET Standard 2.0 library, the only option is upgrading your project to .NET Framework 4.6.1 or later.

The most useful reference is the .NET Standard Compatibility matrix listed in the official documentation, which shows the version compatibility with different .NET implementations:

enter image description here

From here you can see that the first .NET Framework version that can reference a .NET Standard libary is 4.5, and it still cannot reference Standard 2.0, because it is still missing some of the APIs.

For further details check out the .NET Standard documentation.