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 WallpaperPickerViewModel. Thrown when Command.RequestSwitch reply != Ok; Source='WallpaperPickerViewModel'. Triggered after wallpaper switch settings change. Caught locally and shown via IErrorService.
Source
Thrown at AutoDarkModeApp/ViewModels/WallpaperPickerViewModel.cs:325
private void HandleConfigUpdate(object sender, FileSystemEventArgs e)
{
StateUpdateHandler.StopConfigWatcher();
_dispatcherQueue.TryEnqueue(() =>
{
_builder.Load();
LoadSettings();
});
StateUpdateHandler.StartConfigWatcher();
}
private async void RequestThemeSwitch()
{
try
{
var result = await MessageHandler.Client.SendMessageAndGetReplyAsync(Command.RequestSwitch, 15);
if (result != StatusCode.Ok)
{
throw new SwitchThemeException(result, "WallpaperPickerViewModel");
}
}
catch (Exception ex)
{
await _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, "WallpaperPickerViewModel");
}
}
partial void OnIsWallpaperSwitchEnabledChanged(bool value)
{
if (_isInitializing)
{
return;
}
_builder.Config.WallpaperSwitch.Enabled = value;
SafeSaveBuilder();View on GitHub (pinned to c15b28e921)
Solutions
- Verify all configured wallpaper file paths exist and are accessible.
- Ensure no other wallpaper-changing tool is running.
- Check the service log for the wallpaper component error.
- Retry the switch after confirming the service is responsive.
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate every configured wallpaper path exists before requesting a switch
public static bool WallpaperPathsExist(AdmConfigBuilder b) =>
b.Config.WallpaperSwitch.Component.Monitors.All(m => File.Exists(m.ThemeDarkPath) && File.Exists(m.ThemeLightPath)); Try / catch
// Already caught and routed to ShowErrorMessage. Refactor async void -> Task // to let the caller observe the SwitchThemeException.
Prevention
- Validate all wallpaper file paths in config exist and are readable.
- Ensure no other wallpaper tool is active.
- Stop the config watcher (StateUpdateHandler) before programmatic bulk changes to avoid concurrent switches.
- Check the service log for the wallpaper component error.
When it happens
Trigger: WallpaperPickerViewModel.RequestThemeSwitch() runs after a wallpaper setting change (config watcher reload also calls LoadSettings). Reply to RequestSwitch (15s) != 'Ok'.
Common situations: Wallpaper file path is invalid/missing; the wallpaper component in the service failed; another process holds the wallpaper file; service timeout or unreachable.
Related errors
- Theme switching is unsuccessful: {result}
- Theme switching is unsuccessful: {result}
- Theme switching is unsuccessful: {result}
- Theme switching is unsuccessful: {result}
- Theme switching is unsuccessful: {result}
AI-assisted analysis of AutoDarkMode/Windows-Auto-Night-Mode@c15b28e921 (2026-08-13).
Data as JSON: /api/errors/68d191fd53993f8d.
Report an issue: GitHub.