dotnet / winforms

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

"Windows Forms Trace Listener" message box windows appear every time a form containing a UserControl with a "Trace.WriteLine" in its Load event is opened. #12360

Open andregiacomini opened 5 days ago

andregiacomini commented 5 days ago

Environment

VS Version 17.11.5

.NET version

Tested both in .NET 6 and .NET 8

Did this work in a previous version of Visual Studio and/or previous .NET release?

No response

Issue description

When a UserControl has a Trace.WriteLine in the Load event, and this UserControl is added to a form, the following message is shown every time the form is opened.

Steps to reproduce

Diagnostics

No response

Tanya-Solyanik commented 5 days ago

@Olina-Zhang - this issue looks familiar, but I didn't find it in the designer repo , it still repros on the latest. Could you please search for a dupe and create a new one if there is none.

elachlan commented 5 days ago

I think there was a similar issue with #3739

Olina-Zhang commented 5 days ago

@Tanya-Solyanik we have a designer issue: https://github.com/microsoft/winforms-designer/issues/1995 about UserControl with load event contained MessageBox.Show or Dialog.Show, tracked that issue in Winforms runtime 10677, fixed by PR: https://github.com/dotnet/winforms/pull/10710. Now MessageBox in UserControl load event is not popped up at design mode. Do we need to file another designer issue for Trace.WriteLine("Hello from User Control") in the Load event of this UserControl?

Tanya-Solyanik commented 4 days ago

@Olina-Zhang - I can repro on Version 17.13.0 Preview 1.0 [35417.248.main], we fixed only a hang and the MessageBox invocation specifically. We'll triage this one in this repo.

Image

Olina-Zhang commented 4 days ago

@Tanya-Solyanik Yes, I can also repro this one.

Shyam-Gupta commented 2 days ago

The change to display the dialog for Debug.Fail and Debug.Assert was done as a response to this issue. Earlier the Debug.* statements were causing Designer's server process to crash silently. Now these statements show up as text in the message box. I will check if we can special case Trace.* statements and just log them in VS output window instead of displaying them in the message box.