.NET Core 2.1 can't reference a .NET Framework 4.7.2 Class library

13,917

You can reference .NET Standard library instead. So you need to create .NET Standard library with common shared logic and reference it from both - .NET Core and .NET Framework ("full") projects.

Note that while you may be able to use .NET Standard without PackageReference, it's recommended to do it this way. Find more details in Referencing .NET Standard Assemblies from both .NET Core and .NET Framework.

Share:
13,917

Related videos on Youtube

Scott L
Author by

Scott L

Updated on September 16, 2022

Comments

  • Scott L
    Scott L over 1 year

    I have a .NET Core 2.1 app, a .NET MVC website (4.7.2) and I also have a .NET 4.7.2 class library.

    What I'm trying to do is have my core 2.1 project reference the class library.

    Now I've added the reference to the core project with no issues (it builds), but when I try to add the namespace to a class It doesn't come up.

    I want both the app and the MVC site to share the same class library.

    Here's the screen shot:

    There should be another namespace, one called models

    There should be another namespace, one called models

    Any help would be great. Thanks

    • Daniel A. White
      Daniel A. White over 5 years
      does the .net framework library conform to the .net standard?
  • Scott L
    Scott L over 5 years
    That did it, Thanks :)
  • Chau
    Chau about 5 years
    This indeed work, but I also needed to add the <RestoreProjectStyle>PackageReference</RestoreProjectStyle> to the <PropertyGroup> in the csproj file. See S. Hanselman and finally for more issues this.