top of page

Upgrading Windows Forms-Based Desktop Apps to .NET 7



Introduction


There is no denying that desktop applications built with Windows Forms have been widely used for many years, allowing developers to create feature-rich desktop applications with complex user interfaces. However, with the rising demand for high-quality applications with modern user interfaces, it has become essential to upgrade Windows Forms-based desktop applications to .NET 7. Not only does .NET 7 come with command-binding support features that can modernise Windows Forms-based desktop applications through MVVM support, but it also offers other cutting-edge features like high-resolution support through DPI scaling and various new controls like buttons with the dropdown menu. 


Furthermore, upgrading the Windows Forms-based desktop apps to .NET 7 reduces the length of the code-behind class and makes it more accurate, which in turn simplifies the coding process, leading to reduced development time.


The Windows Forms-based project types below can be upgraded with the .NET upgrade assistant.

  

  • Windows Forms Project

  • Control Library

  • .NET Library


By Upgrading to .NET 7, you can not only improve the look and feel of the Windows forms-based apps but can also create high-end Windows forms-based desktop applications in no time.

 

Prerequisites

The following tools and platforms are required as a prerequisite for upgrading Windows Forms-Based desktop apps to .NET 7. 

 

  • Windows Operating System

While developing Windows Form Desktop Apps is possible on any platform, it can run only on a Windows Operating System with .NET 7 installed. That's why a Windows Operating System is required. 


  • Visual Studio 2022 ver 17.1 or later to target .NET 7

The second requirement is Visual Studio 2022 ver 17.1 or later for this upgrade, as this is the minimum version that supports the .NET 7 upgrade. 


  • .NET Upgrade Assistant extension for Visual Studio

Apart from the Visual Studio and Windows operating systems, a .NET Upgrade Assistant extension is required for any kind of upgrade on Visual Studio. 


Note: You can install the .NET Upgrade Assistant extension for Visual Studio from the Manage Extensions in the Extensions tab. Type .NET Upgrade Assistant in the search box. The Upgrade Assistant will appear. Click on download, and follow the steps shown by the installer to install it. Finally, you will need to restart Visual Studio to bring the changes into effect.  


Steps to Upgrade Windows Form-Based Desktop Apps to .NET 7 in Visual Studio


The following steps are required for upgrading a Windows Forms Desktop App project to .NET 7:


Step 1: Upgrading the dependencies


Step 1.1 Initiating the Upgrade Process


  • Select the desired upgrade in Solution Explorer

To initiate the upgrade process, right-click on the dependent library in the Solution Explorer window and select the Upgrade option.


Select the desired upgrade in Solution Explorer

  • Selection of the upgrade to be executed

Once you click on the Upgrade option, a new tab will appear, as shown below, and we can select how to perform the upgrade.


Selection of the upgrade to be executed

  • Select in-place project upgrade

Once you are shown the upgrade options, select the in-place project upgrade.


Select in-place project upgrade

Step 1.2 Selecting the Target Framework


  • Choose the target framework 

Once you have selected the in-place project upgrade option, you need to choose the target framework. 


Note: Users will have different options based on the target framework they want to upgrade. .NET standard 2.0 is a good choice if your library does not rely on desktop technologies like Windows Forms and can be used by both the .NET framework project and the .NET project. The latest NET releases provide many languages and compiler improvements over the .NET standard.

 

  • Select the .NET 7 version

Once you are shown an array of options,  select .NET 7.


Select the .NET 7 version

Step 1.3 Starting the upgrade process


  • Initiating the Upgrade Process

After you select the target framework, click on the Next button. The details of all the project artefacts like code files and libraries, appear. You can upgrade each artefact individually or the entire project, which is the default.


Initiating the Upgrade Process

  •  Selecting the Upgrade

On the Select Component section, leave all the selected artefacts and click the Upgrade Selection Button. 


 Selecting the Upgrade

Once you click on the Upgrade Selection Option, the result will be shown with artefacts with green circles, where solid means upgraded and empty means skipped, as shown in the image below. 


Note: Those artefacts do not hold anything required for upgrading, as found by the upgrade assistant.


Result will be shown with artefacts with green circles

 


Once the supporting library has been upgraded, the next step is to upgrade the main app.

  

Step 2: Upgrading the Main app


Note: The main app can be upgraded once all supporting libraries are upgraded. The demo app that has been used for this guide has only one library project, which has been upgraded in the previous section. Once the dependent libraries have been upgraded to .NET 7,  the next step is to upgrading the main app.


Step 2.1 Initiating the main app upgrade process


  • Select Upgrade Option

To upgrade the main app to .NET 7, right-click on the main app in the Solution Explorer and select the Upgrade option.


Select Upgrade Option

  • Select the project upgrade option

Once you are shown the project mode, select the project upgrade option in the project mode.


Select the project upgrade option

Step 2.2 Selecting the Target Framework 


  • Choose the Target Framework

Select the .NET 7 for the target framework and click on the Next button.


Choose the Target Framework

Step 2.3 Initiating the upgrade process for the main app


  • Select Upgrade Selection

Once you click on the Next button, a list of artefacts appears. Leave all of the artefacts selected and select Upgrade Selection.


Select Upgrade Selection

Step 2.4 Finalising the Upgrade Process


  • Completion of the Upgrade process

Once the upgrade is completed, the results will be shown in the output window. 


Note: For some projects, the Windows Forms project will show the warning symbol. When expanding them, results will be displayed for that step.


Completion of the Upgrade process

Note: The project upgrade component might show that the default font has changed. Fonts can affect the control layout, so you must check each form and custom control in your project to check the UI is arranged correctly.

  

Step 3: Generation of a Clean Build


Note: You must clean and build the main app once the project is upgraded to .NET 7.


Step 3.1: Performing Clean-up Process

  • To initiate the cleanup process, right-click on the main project in the Solution Explorer Window and select the Clean option.

Performing Clean-up Process

Once the cleaning process is completed, the output window will show the details below, confirming that the main app was cleaned without errors.


Output window will show the details

Step 3.2: Generating a fresh build

 

  • Once the main project is cleaned, right-click on it in the Solution Explorer Window and click on the Build option.


Generating a fresh build

Conclusion


It goes without saying that Upgrading Windows Forms-based desktop applications to .NET 7 can be a strategic and beneficial decision. Even though upgrading Windows form-based desktop applications to .NET 7 requires in-depth planning, architectural considerations, and an understanding of the dissimilarities between Legacy Windows Forms and .NET 7 versions, taking the time to analyse your current application’s architecture, dependencies, and components and keeping in mind the above-mentioned steps you can ensure a smoother transition to .NET 7. Are you planning to upgrade your Windows forms-based desktop applications to .NET 7 or further? At Syngis Software Development, we can upgrade your legacy Microsoft applications to the latest versions of Microsoft technologies. We build highly intuitive Windows Desktop-based apps using the most recent versions of Microsoft technology. Contact us now to leverage the maximum out of new Microsoft product releases.

9 views0 comments

Comments


Recent Posts
bottom of page