{"record":{"id":"870ce6b0d5f64aea","repo":"tui-cs/Terminal.Gui","slug":"current-theme-does-not-have-a-scheme","errorCode":null,"errorMessage":"Current Theme does not have a Scheme.","messagePattern":"Current Theme does not have a Scheme\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/SchemeManager.cs","lineNumber":222,"sourceCode":"    }\n\n    /// <summary>\n    ///     Get the dictionary of schemes from the current theme. Current means active.\n    /// </summary>\n    /// <returns></returns>\n    public static Dictionary<string, Scheme?> GetSchemesForCurrentTheme ()\n    {\n        lock (_schemesLock)\n        {\n            if (!ConfigurationManager.IsInitialized ())\n            {\n                throw new InvalidOperationException (\"CM Must be Initialized\");\n            }\n\n            if (ThemeManager.GetCurrentTheme () [\"Schemes\"].PropertyValue is not Dictionary<string, Scheme?> schemes)\n            {\n                // Most likely because \"Schemes\": was left out of the config\n                throw new InvalidOperationException (\"Current Theme does not have a Scheme.\");\n            }\n\n            return schemes;\n        }\n    }\n\n    /// <summary>\n    ///     Convenience method to get the names of the schemes.\n    /// </summary>\n    /// <returns></returns>\n    public static ImmutableList<string> GetSchemeNames ()\n    {\n        lock (_schemesLock)\n        {\n            return GetSchemes ().Keys.ToImmutableList ();\n        }\n    }\n","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/SchemeManager.cs#L204-L240","documentation":"GetSchemesForCurrentTheme reads the active theme's \"Schemes\" config property and expects a Dictionary<string,Scheme?>. If the property value is null or not that dictionary type — typically because the \"Schemes\" key was omitted from the theme config — this InvalidOperationException is thrown.","triggerScenarios":"A theme config JSON that defines settings but omits the \"Schemes\" object entirely; a partially-applied theme; calling GetSchemesForCurrentTheme before the theme's Schemes were populated.","commonSituations":"Custom theme missing the Schemes section; upgrading without including the required Schemes block; ConfigurationManager.Apply on a config lacking Schemes.","solutions":["Ensure the theme JSON includes a \"Schemes\" object (copy the Schemes block from the default theme).","Load a complete theme via ThemeManager, or add schemes via AddScheme.","Use TryGetScheme (which returns false instead of throwing) when absence is expected."],"exampleFix":"// before\n{ \"Theme\": { \"Name\": \"MyTheme\" } }\n// after\n{ \"Theme\": { \"Name\": \"MyTheme\", \"Schemes\": { \"Base\": { \"Normal\": { \"Foreground\": \"White\" } } } } }","handlingStrategy":"validation","validationCode":"bool themesHasSchemes =\n    ThemeManager.GetCurrentTheme () [\"Schemes\"].PropertyValue\n    is Dictionary<string, Scheme?>;","typeGuard":null,"tryCatchPattern":"try { var schemes = SchemeManager.GetSchemesForCurrentTheme (); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains (\"does not have a Scheme\"))\n{ /* theme omitted the Schemes block; fall back to AddScheme or load a full theme */ }","preventionTips":["Always include a Schemes block in custom themes.","Prefer TryGetScheme over GetScheme when absence is possible."],"tags":["config","scheme","theming","runtime-api"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}