winforms icon indicating copy to clipboard operation
winforms copied to clipboard

"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.

Open andregiacomini opened this issue 1 year ago • 5 comments

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

  • Create a new WinForms project
  • Add a UserControl
  • Write Trace.WriteLine("Hello from User Control"); in the Load event of this UserControl
  • Add a Form
  • Add the previously created UserControl to the Form

Diagnostics

No response

andregiacomini avatar Oct 21 '24 13:10 andregiacomini

@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.

Tanya-Solyanik avatar Oct 21 '24 23:10 Tanya-Solyanik

I think there was a similar issue with #3739

elachlan avatar Oct 22 '24 00:10 elachlan

@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?

Olina-Zhang avatar Oct 22 '24 03:10 Olina-Zhang

@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

Tanya-Solyanik avatar Oct 22 '24 19:10 Tanya-Solyanik

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

Olina-Zhang avatar Oct 23 '24 01:10 Olina-Zhang

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.

Shyam-Gupta avatar Oct 24 '24 18:10 Shyam-Gupta

I will check if we can special case Trace.* statements

@Shyam-Gupta - Debug,Assert and maybe Fail too can go into the log too if we can't distinguish the source

Tanya-Solyanik avatar Oct 28 '24 00:10 Tanya-Solyanik

Fix for this issue has been implemented in the designer code and is expected to be available in the next VS preview release.

Shyam-Gupta avatar Oct 31 '24 18:10 Shyam-Gupta

This fix will be in 17.13 preview 1.

merriemcgaw avatar Oct 31 '24 18:10 merriemcgaw

Verified this issue on VS latest build: 17.13.0 Preview 2.0 [35504.150.main], the issue fixed. After add Trace.WriteLine("Hello from User Control"); the "Windows Forms Trace Listener" message box window will not appear when opening other windows

https://github.com/user-attachments/assets/9f9a70c4-7c12-451b-86be-a6237c6c595e

Nora-Zhou01 avatar Nov 05 '24 02:11 Nora-Zhou01