santosh kumar patro
santosh kumar patro

Reputation: 8231

Project 'ClassLibrary1.csproj' targets 'netcoreapp2.1'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7.2'

I have two class library project with the following setting:

Now I referenced the ClassLibrary1 project in ClassLibrary2 project. It was done successfully. But on rebuilding the project I am getting an error:

Severity Code Description Project File Line Suppression State Error Project '..\ClassLibrary1\ClassLibrary1.csproj' targets 'netcoreapp2.1'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7.2'. ClassLibrary2

Can anyone help me to know the reason for this error?

Upvotes: 32

Views: 49200

Answers (2)

gouravm
gouravm

Reputation: 321

I changed my targeting class library to netstandard2.0 and it passed the builds.

Upvotes: 2

Szymon Tomczyk
Szymon Tomczyk

Reputation: 1319

You are not able to reference:

  • .NET Core libraries from .NET Framework
  • .NET Framework libraries from .NET Core

If you want to share code between those two libraries you have to use .NET Standard libraries.

.NET Standard is a kind of interface, a versioned list of APIs that you can call, .NET Framework and .NET Core implements this standard

Please see for reference: .NET Standard

Upvotes: 59

Related Questions