how can I change the .NET to .NET Framework 4.7.2 i am really struggeling since 2 days now. I am doing a WinFormApp and can only use .NET 5 or .NET Core 3.1 but i need .NET Framework 4.7.2 for another Framework. Already installed it through [Microsoft] but it dont appear there to select.
-
In your project file, just use "net472" as the target framework. (You can do that after creating the project.) Note that in the "New project" dialog there are often different *top level* options for creating .NET Framework projects from .NET/.NET Core projects. It's not entirely clear whether this will help, hence the comment rather than an answer... – Jon Skeet Jul 27 '21 at 16:17
-
@JonSkeet do u mean project-> properties -> application -> Target Framework ? there net472 doesnt appear – michi Jul 27 '21 at 16:21
-
1Can't target .Net Framework in a Core app. You can use .Net Standard library – GH DevOps Jul 27 '21 at 16:24
-
@GHDevOps: You you can target .NET Framework in a *project file* though, which is what I was talking about. – Jon Skeet Jul 27 '21 at 16:37
-
No, I don't mean going through whatever the VS dialogs show - I mean opening the .csproj file, finding the `
` element and setting the value to net472. – Jon Skeet Jul 27 '21 at 16:38
2 Answers
You don't need to "restart a project" to target .NET Framework. You just need to use the appropriate TargetFramework element in the csproj file.
Here's an example for a Windows Forms application targeting .NET Framework 4.7.2:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net472</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>
If you create a .NET Core 3.1 or .NET 5 project, you can just edit the .csproj file to specify .NET Framework as the target framework - no need to start from scratch.

- 1,421,763
- 867
- 9,128
- 9,194
-
Why doesn't the GUI provide the option, unless the csproj file is first manually edited? – Amessihel Apr 05 '22 at 20:49
-
1@Amessihel: No idea. But now that the project files are so easy to edit, that's my normal way of doing things. – Jon Skeet Apr 06 '22 at 05:40
Well, as your main application is .NET Core, it's running on a core CLR. It cannot be changed to a non-core CLR project. You would need to restart a project if there is no way of achieving the goal you need.
If you also need the .NET Core application for whatever reason, I would recommend using an API call to communicate between the two applications or another method of communication which isn't with the project itself.

- 30,962
- 25
- 85
- 135

- 162
- 1
- 1
- 10
-
You don't need to use a "non-core" project file to target .NET Framework though. It's absolutely fine to use an SDK-style project with a `TargetFramework` property of net472. – Jon Skeet Jul 27 '21 at 16:37
-
Rolling back from net6.0-windows to net472 seems a bit counterintuitive but it does appear to remove the issue. https://learn.microsoft.com/en-us/answers/questions/363546/adonet-entity-data-model.html and https://learn.microsoft.com/en-us/visualstudio/data-tools/create-a-simple-data-application-with-wpf-and-entity-framework-6?view=vs-2022 – Jamie Jan 02 '22 at 02:30
-
I ran into this problem, because I didn't realize that there was both a Core and a Framework console project that visual studio lets you make. I created a new project as a framework console project and copied all the other code into it, which I wouldn't exactly frame as "restarting" the project. Be advised if you want to change the project name to the original name after you delete the first, incorrect, project, you might need to do some annoying steps- rename the project, rename the folder containing the project, then remove and re-add the project from/to the solution. – ORcoder Jul 07 '22 at 21:55