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

◇◆丶佛笑我妖孽 提交于 2020-01-13 07:52:26

问题


I have two class library project with the following setting:

  • ClassLibrary1 --> Target framework-->.NET Core 2.1
  • ClassLibrary2 --> Target framework-->.NET Framework 4.7.2

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?


回答1:


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



来源:https://stackoverflow.com/questions/53083554/project-classlibrary1-csproj-targets-netcoreapp2-1-it-cannot-be-referenced

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!