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 ThemePickerViewModel. Thrown when Command.RequestSwitch reply != Ok; Source='ThemePickerViewModel'. Called after color/ignore-color settings are written. Caught locally and routed to ShowErrorMessage.

Source

Thrown at AutoDarkModeApp/ViewModels/ThemePickerViewModel.cs:238

    partial void OnIgnoreDesktopIconsEnabledChanged(bool value)
    {
        WriteSettings();
    }

    partial void OnIgnoreColorEnabledChanged(bool value)
    {
        WriteSettings();
    }

    private async void RequestThemeSwitch()
    {
        try
        {
            var result = await MessageHandler.Client.SendMessageAndGetReplyAsync(Command.RequestSwitch, 15);
            if (result != StatusCode.Ok)
            {
                throw new SwitchThemeException(result, "ThemePickerViewModel");
            }
        }
        catch (Exception ex)
        {
            await _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, "ThemePickerViewModel");
        }
    }

}

View on GitHub (pinned to c15b28e921)

Solutions

  1. Ensure no other tool is applying theme/personalization changes simultaneously.
  2. Verify the service is running and review its log.
  3. Retry the switch.
  4. Confirm the 15s timeout is not being exceeded on slow systems.
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify accent color / theme settings are coherent before switching
public static bool AccentSettingsValid(AdmConfigBuilder b) =>
    b.Config.AutoThemeSwitchingEnabled;

Try / catch

// Already caught locally. Refactor to Task-returning if observability needed.
try { await RequestThemeSwitchAsync(); }
catch (SwitchThemeException ex) { /* log ex.Source */ }

Prevention

When it happens

Trigger: ThemePickerViewModel.RequestThemeSwitch() runs after an accent/ignore-color setting change (e.g. OnIgnoreColorEnabledChanged -> WriteSettings -> RequestThemeSwitch). Reply != 'Ok'.

Common situations: Accent color or theme application failed in the service; service busy; timeout; conflicting personalization tools holding registry locks.

Related errors


AI-assisted analysis of AutoDarkMode/Windows-Auto-Night-Mode@c15b28e921 (2026-08-13). Data as JSON: /api/errors/23148ea84bbae8e0. Report an issue: GitHub.