winforms icon indicating copy to clipboard operation
winforms copied to clipboard

DemoConsole app: An exception pops up when focusing on "Type Here" in contextMenuStrip under DarkMode

Open Olina-Zhang opened this issue 7 months ago • 0 comments

.NET version

The latest main branch of Winforms repo

Did it work in .NET Framework?

Not tested/verified

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes. It was regressed from the PR: https://github.com/dotnet/winforms/pull/13360

Issue description

In DemoConsole test app of WinForms repo, an exception pops up when focusing on "Type Here" in contextMenuStrip under DarkMode

Image

Exception log: System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=System.Windows.Forms StackTrace: at System.Windows.Forms.ToolStripSystemDarkModeRenderer.OnRenderArrow(ToolStripArrowRenderEventArgs e) in C:\Users\xxx\source\repos\winforms\src\System.Windows.Forms\System\Windows\Forms\Controls\ToolStrips\ToolStripSystemDarkModeRenderer.cs:line 566

https://github.com/user-attachments/assets/16e49163-1cc7-4748-a804-22ec36bf37a9

Steps to reproduce

  1. Find the sample app: DemoConsole in Winforms repo
  2. Change it to .NET targeting only from Multi-targets
  3. Enable Dark mode by adding below code lines in the Program.cs file under DemoConsole project
#pragma warning disable WFO5001
        Application.SetColorMode(SystemColorMode.Dark);
#pragma warning restore WFO5001
  1. Run DemoConsole app
  2. Find ContextMenuStrip control in 'Use SnapLines' tabPage, then move mouse to 'Type Here' area

Olina-Zhang avatar Jun 19 '25 06:06 Olina-Zhang