dotnet / winforms

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

[DarkMode] 'Application' does not contain a definition for 'SetColorMode' after .NET 10.0 is installed #12292

Closed chaowendy closed 1 month ago

chaowendy commented 1 month ago

.NET version

9.0.100-rc.2.24474.11

Did it work in .NET Framework?

No

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

This is a new feature Dark Mode: https://github.com/dotnet/winforms/pull/11857

Issue description

When enable DarkMode by Application.SetColorMode(SystemColorMode.Dark) in Program.cs file with .NET 10.0 installed, there are 2 errors as follows: image

More Info: After uninstalling .NET 10.0, the 2 errors disappeared image

Steps to reproduce

  1. Install .NET 10.0 SDK ;
  2. Create a .NET Winforms project ;
  3. Enable DarkMode by Application.SetColorMode(SystemColorMode.Dark) in Program.cs file and observe.
KlausLoeffelmann commented 1 month ago

.NET 10 SDK is in alpha, and I am not sure at this point, that everything is integrating already as it is supposed to be.

But I agree, it sounds peculiar that the 10 SDK would then overwrite, what, the WinForms reference assemblies? And also, with what version? 8? Weird.

Let me take a look.

KlausLoeffelmann commented 1 month ago

As I said. Currently, the .NET 10 alpha pulls in:

C:\.tools\.nuget\packages\microsoft.windowsdesktop.app.ref\9.0.0-preview.7.24405.2\ref\net9.0\System.Windows.Forms.dll

Which is not the correct version. I expect this to change with upcoming versions. Closing this, as it will get fixed once the integration is up to date.

@JeremyKuhne, @Shyam-Gupta.

chaowendy commented 1 month ago

Hi @KlausLoeffelmann , there are 3 scenarios:

  1. DarkMode is supported when I install SDK 10.0 and create a 10.0 project.
  2. DarkMode is not supported when I install SDK 10.0 and create a 9.0 project.
  3. DarkMode is supported when I uninstall SDK 10.0 and create a 9.0 project.

So from the last 2 scenarios, with the SDK 10.0 installed, Dark theme for 9.0 project is not supported. Is that expected? Thanks.