How to use existing .net framework 4.8 class library in .NET 6 project?

Jay Vansjalia 1 Reputation point
2022-01-31T09:33:55.023+00:00

We have .NET 6 Blazor Server-side project in Visual Studio 2022. We would like to use .Net Framework 4.8 class library in .NET 6. In this class library, we are using System.Windows.Form and we cannot recompile the class library with .NET Standard 2.0.

I have added .Net Framework 4.8 class library project as dependency for Blazor Application. I am able to compile the solution but when try to run the Blazor Application then it complaints with "System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.".

We would just like to run Blazor project in windows only.

Developer technologies .NET Blazor
Developer technologies .NET .NET Runtime
Developer technologies C#
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2022-01-31T10:32:22.813+00:00

    You can not use your .NET Framework 4.8 project with your .NET Core 6 project.

    Second opinion https://stackoverflow.com/questions/70923650/how-can-i-use-existing-net-framework-4-8-class-library-in-net-6-project

    Regarding compatibility mode if going this route make sure to test current code and look-ahead and what may come down the road.

    In closing, every single one of my Framework 4.8 project were rewritten for .NET Core, didn't want to chance anything along with wanting better performance.

    0 comments No comments

  2. Philchel-8024 106 Reputation points
    2022-01-31T10:56:59.817+00:00
    0 comments No comments

  3. cleric145-6909 11 Reputation points
    2022-01-31T11:23:31.357+00:00
    0 comments No comments

Your answer

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