Home > Back-end >  Visual Studio 2022 Missing Template for Form (Windows Forms)
Visual Studio 2022 Missing Template for Form (Windows Forms)

Time:06-15

Running Visual Studio 17.2.3. I've got a solution that consists of many projects built against.Net5. I've suddenly lost the ability to add forms to dependent projects. If I try to add a new form to a project, the "Form (Windows Forms)" template does not display when clicking on "Add->New Item..." for the selected sub-project. However, if I select the project set as the "startup project" and click on "Add->New Item...", the Form template does appear.

I've tried using the solution indicated in "Missing Windows Form Templates in newly Installed Visual Studio 2015" in particular, running 'devenv /Intalltemplates" but it did nothing.

UPDATE: June 9 - I added a new project to the solution. I noticed that when adding a new item to the new project, it did display "Form (Windows Forms)" as a template. I also noticed a difference in the dependent frameworks. The projects that show the form template all contain a dependency on "Microsoft.WindowsDesktop.App.WindowsForms". Is there any way to add this dependency?

CodePudding user response:

After looking into my update above, I found that the following flag was missing from the projects that no longer allowed for adding a Form to the project:

<UseWindowsForms>true</UseWindowsForms>

I'm not sure why the flag was removed. Once I added the above flag to the affected projects, "Forms" then reappeared as a template.

I started to notice the problem after I had updated Visual Studio 2022 to version 17.2.3. I'm not sure if that is related.

  • Related