AutoDarkMode/Windows-Auto-Night-Mode · warning · SwitchThemeException
Theme switching is unsuccessful: {result}
Error message
Theme switching is unsuccessful: {result} What it means
Same RequestThemeSwitch pattern in SystemAreasViewModel. Thrown when Command.RequestSwitch reply != Ok; Source='SystemAreasViewModel'. The method comment 'TODO: Different processing methods from TimeViewModel' signals known divergence. Caught locally and shown via IErrorService.
Source
Thrown at AutoDarkModeApp/ViewModels/SystemAreasViewModel.cs:189
{
StateUpdateHandler.StopConfigWatcher();
_dispatcherQueue.TryEnqueue(() =>
{
_builder.Load();
LoadSettings();
});
StateUpdateHandler.StartConfigWatcher();
}
// TODO: Different processing methods from TimeViewModel
private async void RequestThemeSwitch()
{
try
{
var result = await MessageHandler.Client.SendMessageAndGetReplyAsync(Command.RequestSwitch, 15);
if (result != StatusCode.Ok)
{
throw new SwitchThemeException(result, "SystemAreasViewModel");
}
}
catch (Exception ex)
{
await _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, "SystemAreasViewModel");
}
}
partial void OnAppsSwitchComponentModeChanged(AppSwitchMode value)
{
if (_isInitializing)
return;
if (value != AppSwitchMode.Disabled)
{
_builder.Config.AppsSwitch.Enabled = true;
_builder.Config.AppsSwitch.Component.Mode = value switch
{
View on GitHub (pinned to c15b28e921)
Solutions
- Confirm AutoDarkModeSvc has the privileges needed for system-area changes.
- Check the service log for which system area failed.
- Retry after ensuring no other theme-changing process is active.
- Verify the 15s timeout is adequate for multi-area switches.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check that system-area registry keys are writable by the service context
public static bool CanWriteSystemAreas() =>
System.Security.Principal.WindowsIdentity.GetCurrent().Owner != null; // run elevated if needed Try / catch
// Already caught and routed to ShowErrorMessage. Refactor async void -> Task // if the caller needs to observe the SwitchThemeException.
Prevention
- Run the service with privileges sufficient for system-area registry writes.
- Close competing personalization/theme tools before switching.
- Resolve the TODO (divergence from TimeViewModel) to standardize processing.
- Check the service log for the specific system area that failed.
When it happens
Trigger: SystemAreasViewModel.RequestThemeSwitch() runs (after a system-areas setting change). Reply to RequestSwitch (15s) != 'Ok'.
Common situations: A system-area component (taskbar, registry-based theme area) failed to apply; service returned Err with details; privilege issues writing to system theme registry keys; timeout.
Related errors
- Theme switching is unsuccessful: {result}
- Theme switching is unsuccessful: {result}
- Theme switching is unsuccessful: {result}
- Theme switching is unsuccessful: {result}
- Could not add Auto Dark Mode to autostart
AI-assisted analysis of AutoDarkMode/Windows-Auto-Night-Mode@c15b28e921 (2026-08-13).
Data as JSON: /api/errors/f91a2b7b48ff2d18.
Report an issue: GitHub.