How to use .net 6.0 library in .net framework 4.7.2 project

Chao Li 26 Reputation points Microsoft Employee
2023-06-08T11:58:31.6233333+00:00

My project based on .net framework 4.7.2, and I have to use a .net 6.0 library in my .net framework 4.7.2 project. My questions is how to use .net 6.0 library in .net framework 4.7.2? The .net 6.0 library used other .net 6.0 library, I don't know if there is a way to publish the .net 6.0 library as .net standard 2.0 library, so that I can use the standard 2.0 library in my .net framework project.

Is there any other better way? Below is properties of .net 6.0 library:

User's image

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,372 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,245 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,119 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,036 Reputation points
    2023-06-08T12:25:33.81+00:00

    You can not mix .NET Framework with .NET Core Framework. If the .NET Core project does not use newer features than make a .NET Framework version, otherwise update the .NET Framework project to .NET Core Framework.

    0 comments No comments

  2. Bruce (SqlWork.com) 55,686 Reputation points
    2023-06-08T15:39:18.57+00:00

    .net 4.7/4.8 can not call .net 6 directly nor thru .net standard 2.0. nor can .net 6 call 4.7/4.8 directly or thru .netstandard 2.0

    .netstandard 2.0 projects should only reference other .netstandard 2.0 projects.

    if you can not convert your 4.7 to net 6.0 and you need to call the net 6 code, then host the net 6 code as a webapi, and call via httpclient() from the 4.7 code.

    0 comments No comments