dotnet / winforms

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

Visual Studio crashes when disabling form.ShowInTaskbar and calling form.ShowDialog at DesignTime in .Netcore #11442

Closed ChidanandMurugaiah closed 4 months ago

ChidanandMurugaiah commented 5 months ago

Description

In WinForms, there is an issue where Visual Studio crashes when trying to show a form in design time after disabling the form.ShowInTaskbar property. I have replicated this issue by creating a custom control with a property. In the property setter, I initialize a new form, disable the ShowInTaskBar property, and then call the ShowDialog method. When I try to change the value of the property in the property window, Visual Studio crashes.

Note: - This issue occurs only in .Netcore. It works properly in .NetFramework.

Sample Link - CustomControl.zip

Reproduction Steps

1.Open the Design page. 2.Drag and Drop the custom control. 3.Open the property window. 4.Change the NativeCheck method value to true.

Expected behavior

Need to show the form properly.

Actual behavior

Visual Studio crashes

Regression?

No response

Known Workarounds

No response

Configuration

Sample version - .Net80 Edition -Windows 11 Enterprise Version - 23H2 OS build - 22631.3593 Experience - Windows Feature Experience Pack 1000.22700.1003.0 Visual Studio version - 17.9.7

Other information

No response

huoyaoyuan commented 5 months ago

It's better to open this issue at https://github.com/dotnet/winforms to get eyes from the team. @dotnet/dotnet-winforms

merriemcgaw commented 5 months ago

@Olina-Zhang can you help @ChidanandMurugaiah find the right documentation to help accomplish his goals?

Tanya-Solyanik commented 5 months ago

Use DesignMode as a starting point

ChidanandMurugaiah commented 5 months ago

@Tanya-Solyanik, We are not clear about your explanation regarding using DesignMode as a starting point. Could you please provide an example or a reference to clarify?

Tanya-Solyanik commented 5 months ago

Something like this: if (!DesignMode) { show the form }

ChidanandMurugaiah commented 5 months ago

We need to display the form while interacting with the Designer, so using DesignMode is not a valid solution for our issue. Could you please provide us with an alternative solution?

merriemcgaw commented 4 months ago

There is a blog with instructions on how to create complex WinForms controls for the out-of-process designer. This should answer your questions.