{"record":{"id":"23148ea84bbae8e0","repo":"AutoDarkMode/Windows-Auto-Night-Mode","slug":"theme-switching-is-unsuccessful-result-23148e","errorCode":null,"errorMessage":"Theme switching is unsuccessful: {result}","messagePattern":"Theme switching is unsuccessful: (.+?)","errorType":"exception","errorClass":"SwitchThemeException","httpStatus":null,"severity":"warning","filePath":"AutoDarkModeApp/ViewModels/ThemePickerViewModel.cs","lineNumber":238,"sourceCode":"\n    partial void OnIgnoreDesktopIconsEnabledChanged(bool value)\n    {\n        WriteSettings();\n    }\n\n    partial void OnIgnoreColorEnabledChanged(bool value)\n    {\n        WriteSettings();\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, \"ThemePickerViewModel\");\n            }\n        }\n        catch (Exception ex)\n        {\n            await _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, \"ThemePickerViewModel\");\n        }\n    }\n\n}\n","sourceCodeStart":220,"sourceCodeEnd":248,"githubUrl":"https://github.com/AutoDarkMode/Windows-Auto-Night-Mode/blob/c15b28e92138a1baff6165bbca80842f06cb819f/AutoDarkModeApp/ViewModels/ThemePickerViewModel.cs#L220-L248","documentation":"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.","triggerScenarios":"ThemePickerViewModel.RequestThemeSwitch() runs after an accent/ignore-color setting change (e.g. OnIgnoreColorEnabledChanged -> WriteSettings -> RequestThemeSwitch). Reply != 'Ok'.","commonSituations":"Accent color or theme application failed in the service; service busy; timeout; conflicting personalization tools holding registry locks.","solutions":["Ensure no other tool is applying theme/personalization changes simultaneously.","Verify the service is running and review its log.","Retry the switch.","Confirm the 15s timeout is not being exceeded on slow systems."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify accent color / theme settings are coherent before switching\npublic static bool AccentSettingsValid(AdmConfigBuilder b) =>\n    b.Config.AutoThemeSwitchingEnabled;","typeGuard":null,"tryCatchPattern":"// Already caught locally. Refactor to Task-returning if observability needed.\ntry { await RequestThemeSwitchAsync(); }\ncatch (SwitchThemeException ex) { /* log ex.Source */ }","preventionTips":["Ensure no other personalization tool is changing the accent/theme concurrently.","Debounce OnIgnoreColorEnabledChanged so rapid toggles do not stack switches.","Confirm the service is running before the picker page loads.","Review the service log on persistent non-Ok replies."],"tags":["theme-switch","ipc","named-pipe","theme-picker"],"backgroundTag":null,"analyzedSha":"c15b28e92138a1baff6165bbca80842f06cb819f","analyzedAt":"2026-08-13T21:04:56.049Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}