10

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.

8
  • 7
    Short answer: you can't. Commented Jan 31, 2022 at 9:38
  • 5
    .NET 6 and .NET Framework 4.8 are no interoperable. You will have to migrate and recompile the 4.8 library to either .NET 6 or .NET Standard. Commented Jan 31, 2022 at 9:41
  • Does this answer your question? Can I add a reference to a .NET Framework DLL from a .NET 6 project? Commented Sep 21, 2022 at 14:41
  • 3
    Contrary to the comments and to my surprise, I can create a new core app inside my old solution, and access my old .net framework libraries in that same solution... So I am accessing my 4.8 libraries from a .NET 6 console app... Commented Nov 8, 2022 at 16:03
  • 3
    Same here, same surprise. I created a .NET 7 webapi project, reference a framework 4.8 project. Just works... ¯_(ツ)_/¯ Commented Feb 1, 2023 at 8:11

1 Answer 1

-1

You can target newer .NET versions with inclusion of Windows forms.

See the official guidance

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.