{"record":{"id":"68d191fd53993f8d","repo":"AutoDarkMode/Windows-Auto-Night-Mode","slug":"theme-switching-is-unsuccessful-result-68d191","errorCode":null,"errorMessage":"Theme switching is unsuccessful: {result}","messagePattern":"Theme switching is unsuccessful: (.+?)","errorType":"exception","errorClass":"SwitchThemeException","httpStatus":null,"severity":"warning","filePath":"AutoDarkModeApp/ViewModels/WallpaperPickerViewModel.cs","lineNumber":325,"sourceCode":"    private void HandleConfigUpdate(object sender, FileSystemEventArgs e)\n    {\n        StateUpdateHandler.StopConfigWatcher();\n        _dispatcherQueue.TryEnqueue(() =>\n        {\n            _builder.Load();\n            LoadSettings();\n        });\n        StateUpdateHandler.StartConfigWatcher();\n    }\n\n    private async void RequestThemeSwitch()\n    {\n        try\n        {\n            var result = await MessageHandler.Client.SendMessageAndGetReplyAsync(Command.RequestSwitch, 15);\n            if (result != StatusCode.Ok)\n            {\n                throw new SwitchThemeException(result, \"WallpaperPickerViewModel\");\n            }\n        }\n        catch (Exception ex)\n        {\n            await _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, \"WallpaperPickerViewModel\");\n        }\n    }\n\n    partial void OnIsWallpaperSwitchEnabledChanged(bool value)\n    {\n        if (_isInitializing)\n        {\n            return;\n        }\n\n        _builder.Config.WallpaperSwitch.Enabled = value;\n\n        SafeSaveBuilder();","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/AutoDarkMode/Windows-Auto-Night-Mode/blob/c15b28e92138a1baff6165bbca80842f06cb819f/AutoDarkModeApp/ViewModels/WallpaperPickerViewModel.cs#L307-L343","documentation":"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.","triggerScenarios":"WallpaperPickerViewModel.RequestThemeSwitch() runs after a wallpaper setting change (config watcher reload also calls LoadSettings). Reply to RequestSwitch (15s) != 'Ok'.","commonSituations":"Wallpaper file path is invalid/missing; the wallpaper component in the service failed; another process holds the wallpaper file; service timeout or unreachable.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate every configured wallpaper path exists before requesting a switch\npublic static bool WallpaperPathsExist(AdmConfigBuilder b) =>\n    b.Config.WallpaperSwitch.Component.Monitors.All(m => File.Exists(m.ThemeDarkPath) && File.Exists(m.ThemeLightPath));","typeGuard":null,"tryCatchPattern":"// Already caught and routed to ShowErrorMessage. Refactor async void -> Task\n// to let the caller observe the SwitchThemeException.","preventionTips":["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."],"tags":["theme-switch","ipc","named-pipe","wallpaper"],"backgroundTag":null,"analyzedSha":"c15b28e92138a1baff6165bbca80842f06cb819f","analyzedAt":"2026-08-13T21:04:56.049Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}