Hi, @Osamah Hadi
You can't simply convert from .NET to .NET Framework.
Please create a new Winform project and try the steps below.
. Net and. Net Framework code are different. You need to modify program.cs file.
namespace WinFormsApp1
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}
.NET Framework:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Modify the Winform.csproj file.
<TargetFramework>net6.0-windows</TargetFramework>
to <TargetFramework>.NETFramework,Version=v4.7.2</TargetFramework>
Remove content below that not supported in .NET Framework:
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Save and reopen the project after modifying the above content. There are many errors, which are caused by missing reference namespaces.
E.g.
using System;
using System.Windows.Forms;
Now the Winform project will be able to compile and run.
Summarize:
1.Update project references: update project references to accommodate .NET Framework 4.8. Removed references specific to .NET 6 and added references to .NET Framework 4.8.
2.Change Namespace: change the namespace to accommodate the structure of a .NET Framework 4.8 project.
3.Change incompatible APIs: Based on features and APIs that are not supported in .NET Framework 4.8, manually change your code to use .NET Framework 4.8-compatible alternatives or workarounds.
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.