dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.41k stars 984 forks source link

Designer becomes busted if you remove WinForms references from the project #4508

Closed davkean closed 2 years ago

davkean commented 3 years ago
  1. Create a new Windows Forms (.NET 5) project
  2. Double-click the project file
  3. Delete <UseWindowsForms>true</UseWindowsForms>
  4. Save

Expected: The designer to show a friendly error that it can't render similar to .NET Framework Actual:

---------------------------
Microsoft Visual Studio
---------------------------
Timed out while connecting to named pipe.
---------------------------
OK   
---------------------------

And the "designer" itself no longer renders correctly and just shows the last source file behind it:

image

If you readd back <UseWindowsForms>true</UseWindowsForms> and save you get:

---------------------------
Microsoft Visual Studio
---------------------------
Could not retrieve IDesignToolsClient for project WinFormsApp4.
---------------------------
OK   
---------------------------
Zheng-Li01 commented 3 years ago

The issue can reproduce from .NET SDK 3.1 to 6.0, the icon of "Form1.cs" node disappeared after uncommented <UseWindowsForms>true</UseWindowsForms>; and the icon of "Form1.cs" node appear after re-add back <UseWindowsForms>true</UseWindowsForms>, then double click it, the Form1.cs[Design] load successfully, please see below reproduce GIF. GH4508

merriemcgaw commented 3 years ago

@Zheng-Li01 can you copy this issue over to the internal designer repo?

Zheng-Li01 commented 3 years ago

@merriemcgaw, have filed designer issue to track it.