简体   繁体   中英

Creating a project in Visual Studio with Windows Forms and the .NET Framework

I've been trying to create a new project with the layered architecture using layers like: Presentation (Windows Forms Application with .NET Framework), Data (Class Library), Common (Class Library) and Domain (Class Library). When referencing my Presentation layer to the domain layer and common layer, an error like the following occurs that I don't know what it means and I don't know how to fix it: There is no feedback from visual studio on the error

Also if I want to run or clean the project an error appears that mentions the following:

Project "..\Dominio\Dominio.csproj" has "net6.0" as target. You cannot reference this a project with ".NET Framework,Version=v4.7.2" as the target. Presentation

How can I fix the problem?

I have tried to change the version of .NET in each layer of the project, besides that I have repeated the same procedure several times creating the project from 0.

.NET Core and .NET Framework projects are not compatible. .NET 5 and later are based on .NET Core. You need to target the same framework in all projects. Either target .NET 6 in all projects or .NET Framework in all projects, or you can target .NET Standard in your library projects and then reference them in .NET Core and .NET Framework projects.

You messed up by not paying attention when creating the projects in the first place. I think you can convert a .NET Framework project to .NET Core, but I'm not sure that it's trivial. When creating projects, pay attention to the project template name - those that target .NET Framework say so in the name - and make sure that all projects that need to work together are compatible.

.Net 6 is based on.Net Core. you cannot refer to a .net framework class library in a.Net 5 or 6 project. So you should create a.Net standard library if you want it to be referred to in both the.Net framework and .net core framework.

Here is the list of compatible versions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM