Home > Software design >  How to reference .Net 6.0 dll in .Net Framework 4.8
How to reference .Net 6.0 dll in .Net Framework 4.8

Time:11-08

Good day Everyone! I have a Class Library project which targets .Net framework 6.0. When I reference this dll into another project which targets .Net framework 4.8, I get the following error message

enter image description here

I will appreciate your help.

CodePudding user response:

The short answer is "you can't". .NET 6 and .Net Framework 4.8 are entirely different beasties, and not compatible with each other.

If you want a library that will work in .NET Framework and .NET, you'll want to look into .NET Standard, specifically version 2.0. It's not got everything in, but it can be referenced from both .NET Framework and .NET 5/6 (and earlier versions of Core).

That being said (h/t PMF), it would be better still if you were able to update the application to be .NET 6. WinForms (which from your screenshot it looks like you're using) is supported in .NET 6, so it should be fairly straightforward to make the change.

CodePudding user response:

A project runs on .NET Framework and now want to port them to .NET 6. Of course, you can choose to migrate manually, but a more convenient way is to use the upgrade assistant provided by Microsoft to complete this operation.

  1. The first is to install the upgrade assistant. Execute in the command window: dotnet tool install -g upgrade-assistant.

  2. Since the .NET Upgrade Assistant is installed as a .NET tool, it can be easily updated by running the following command: dotnet tool update -g upgrade-assistant.

  3. Project upgrade. Run the upgrade-assistant analyze command in a command window, passing in the name of the project or solution being upgraded. Run the upgrade-assistant upgrade command, passing in the name of the project or solution being upgraded.

For detailed steps, please refer to the official website document--Using the .NET Upgrade Assistant to upgrade WPF applications to .NET 6.

  • Related