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

Developer technologies | .NET | .NET Runtime
Developer technologies | .NET | Other
Developer technologies | C#
Developer technologies | 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.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,596 Reputation points Volunteer Moderator
    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) 82,146 Reputation points Volunteer Moderator
    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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.