We have just moved to .NET and we are trying to recreate one of our old projects with C#/.NET, we have heard that .NET Core is the way to go for new projects and we are very much interested in using WinForms for this, so i have been experimenting with Visual Studio 2019 Preview (16.5.0 Preview 2.0), but i've noticed that not all the controls show up in the designer (i know the designer was just added to the preview), so i tried to add the controls manually on Form1.designer.cs, but im not really sure if this is the right way to do this or should we just wait for more mature releases or just use .NET Framework ? PS: We can go with WPF too if its more supported with .NET Core.
Thank you
. Net Core does not support desktop application development and it rather focuses on the web, windows mobile, and windows store. . Net Framework is used for the development of both desktop and web applications as well as it supports windows forms and WPF applications.
NET 5 or later. The . NET SDK includes support for Windows Forms applications. Windows Forms is still a Windows-only framework and only runs on Windows.
NET 5 / . NET 6 extends support for desktop technologies - WinForms and WPF, and continues to unify all . NET development frameworks.
NET Core 3.1 was originally released on December 3, 2019 and is supported for three years. But the actual end of support day will be the closest Patch Tuesday starting that date, which is December 13, 2022.
Does Winforms (.NET Core 3) support all .NET Framework controls?
No, it doesn't. In fact in .NET Core 3.1 some of the outdated Windows Forms controls like DataGrid
, ToolBar
, ContextMenu
, Menu
, MainMenu
, MenuItem
, and their child components were removed.
You need to use DataGridView
, ToolStrip
, ContextMenuSrtip
, MenuStrip
and their child components instead.
To see a list of removed controls and required actions for upgrade take a look at:
I've noticed that not all the controls show up in the designer
Right, the design-time support is still under development and some of the controls and feature are still not available through designer. However if you don't want to use designer, you just need run-time support, use the controls which are supported by .NET CORE 3.1 but don't have design-time support.
Should we just wait for more mature releases or just use .NET Framework?
At time of writing this answer, if you need to use designer on a regular basis, it's still not recommended to port your application to .NET Core. While there is builtin designer support in VS 2019 Version 16.5 Preview 1, but the designer is still under development and some important features like data-binding, some of container controls, localization, MenuStrip and ToolStrip, Visual inheritance and so on ate not available.
To see the list of under development features take a look at:
This simple trick can easily activate all the missing controls to start your Winforms .Net Core 3.1
Before you do these steps, just know that is only confirmed for testing, and not for production yet. one It is confirmed for final production application, I will update the post.
this solution is confirmed for me with .Net Framework 4.8 and .net Core 3.1.
with some steps as following: 1- Create your winofrms .Net Core project. 2- Press on project_name.csproj and change this:
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
to this new one:
<TargetFrameworks>net48;netcoreapp3.1</TargetFrameworks>
3- Then open Program.cs and comment this
Application.SetHighDpiMode(HighDpiMode.SystemAware);
To be like this:
//Application.SetHighDpiMode(HighDpiMode.SystemAware);
this solution will add all the controls. just close the solution and reopen.
4- After you finish your application, just change everything to default again like this:
Press on project_name.csproj and change this:
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
For the program.cs uncomment, even after I rolled back to default, the application give an error for this line, so I keep it commented
Thanks goes for Kirsan
https://devblogs.microsoft.com/dotnet/updates-to-net-core-windows-forms-designer-in-visual-studio-16-5-preview-1/#comment-4562
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With