AutoDarkMode/Windows-Auto-Night-Mode · warning · SwitchThemeException
Theme switching is unsuccessful: {result}
Error message
Theme switching is unsuccessful: {result} What it means
Thrown by ColorizationViewModel.RequestThemeSwitch when the service reply to Command.RequestSwitch (with a 15-second timeout) is not StatusCode.Ok. SwitchThemeException formats the message as 'Theme switching is unsuccessful: {result}' where {result} is the raw status string returned. The method is async-void and already wraps everything in try/catch that routes to IErrorService.ShowErrorMessage.
Source
Thrown at AutoDarkModeApp/ViewModels/ColorizationViewModel.cs:71
try
{
_skipConfigUpdate = true;
_builder.Save();
}
catch (Exception ex)
{
_errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, "ColorizationViewModel");
}
}
public async void RequestThemeSwitch()
{
try
{
var result = await MessageHandler.Client.SendMessageAndGetReplyAsync(Command.RequestSwitch, 15);
if (result != StatusCode.Ok)
{
throw new SwitchThemeException(result, "ColorizationViewModel");
}
}
catch (Exception ex)
{
await _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, "ColorizationViewModel");
}
}
public ColorizationViewModel(IErrorService errorService)
{
_dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
_errorService = errorService;
try
{
_builder.Load();
}
catch (Exception ex)View on GitHub (pinned to c15b28e921)
Solutions
- Check that AutoDarkModeSvc is running and responsive.
- Review the service log for the specific component that failed during the switch.
- Retry the theme switch after a brief delay (transient component lock).
- Increase or verify the 15-second timeout is sufficient for slow systems.
Defensive patterns
Strategy: try-catch
Validate before calling
// Best-effort pre-check that the service can switch before requesting
public static async Task<bool> CanSwitchAsync()
{
try { var r = await MessageHandler.Client.SendMessageAndGetReplyAsync(Command.RequestSwitch, 15); return r == StatusCode.Ok; }
catch { return false; }
} Try / catch
// RequestThemeSwitch already catches and routes to _errorService.
// Callers need not wrap it (async-void), but should react to the error dialog.
// To make it observable, refactor to Task and await:
// private async Task RequestThemeSwitchAsync() { try {...} catch {...} } Prevention
- Ensure the service is idle before requesting a switch (avoid overlapping switches).
- Review the service log when a non-Ok status appears.
- Keep the 15s timeout adequate for the slowest target system.
- Debounce rapid setting changes so multiple switches do not queue/collide.
When it happens
Trigger: ColorizationViewModel.RequestThemeSwitch() is called (e.g. after a colorization setting change). SendMessageAndGetReplyAsync(Command.RequestSwitch, 15) returns a value != 'Ok' (e.g. 'Err', 'Timeout', or an error detail string). The exception is thrown and immediately caught by the surrounding catch.
Common situations: Service is busy or the theme switch component failed; the 15s timeout elapsed and the reply is 'Timeout'; the service returned an error detail because a sub-component (apps, wallpaper, system) failed to apply; service not running.
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/acb285e4cc89e325.
Report an issue: GitHub.