"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.
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
@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.
I think there was a similar issue with #3739
@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 - 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.
@Tanya-Solyanik Yes, I can also repro this one.
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.
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
Fix for this issue has been implemented in the designer code and is expected to be available in the next VS preview release.
This fix will be in 17.13 preview 1.
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