Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Version introduced: .NET 9
System.Windows.Forms.Application.SetColorMode(System.Windows.Forms.SystemColorMode)is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
—or—
System.Windows.Forms.SystemColorModeis for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
The color mode feature is currently experimental and subject to change. This error is generated so that you understand the implications of writing code that sets the color mode of the Windows Forms project. The error must be suppressed to continue. For more information about this API, see Dark mode.
Note
This compiler error no longer applies starting with .NET 10.
Example
The following sample generates WFO5001:
namespace MyExampleProject;
static class Program
{
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
Application.SetColorMode(SystemColorMode.Dark);
Application.Run(new Form1());
}
}
To correct this error
Upgrade to .NET 10 or later, where this feature is no longer considered experimental.
- or -
Suppress the error and enable access to the API by either of the following methods:
Set the severity of the rule in the .editorConfig file.
[*.{cs,vb}] dotnet_diagnostic.WFO5001.severity = noneFor more information about editor config files, see Configuration files for code analysis rules.
Add the following
PropertyGroupto your project file:<PropertyGroup> <NoWarn>$(NoWarn);WFO5001</NoWarn> </PropertyGroup>Suppress in code with the
#pragma warning disable WFO5001directive:namespace MyExampleProject; static class Program { [STAThread] static void Main() { ApplicationConfiguration.Initialize(); #pragma warning disable WFO5001 Application.SetColorMode(SystemColorMode.Dark); #pragma warning restore WFO5001 Application.Run(new Form1()); } }
.NET Desktop feedback