{"record":{"id":"8a7bba63a6f02271","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"dism-output-has-invalid-format","errorCode":null,"errorMessage":"Dism output has invalid format","messagePattern":"Dism output has invalid format","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"source/KlocTools/IO/DismTools.cs","lineNumber":55,"sourceCode":"        /// Get a list of feature names and their status (true for enabled)\n        /// </summary>\n        public static IEnumerable<KeyValuePair<string, bool>> GetWindowsFeatures()\n        {\n            var output = RunDismCommand(\"/english /format:list /online /get-features\");\n\n            var results = new List<KeyValuePair<string, bool>>();\n            string storedFeatureName = null;\n\n            foreach (var line in output.Split(StringTools.NewLineChars.ToArray(), StringSplitOptions.RemoveEmptyEntries))\n            {\n                if (line.StartsWith(\"Feature Name\", StringComparison.Ordinal))\n                {\n                    storedFeatureName = line.Substring(line.IndexOf(':') + 2);\n                }\n                else if (line.StartsWith(\"State\", StringComparison.Ordinal))\n                {\n                    if (storedFeatureName == null)\n                        throw new InvalidDataException(\"Dism output has invalid format\");\n\n                    var isEnabled = line.Substring(line.IndexOf(':') + 1)\n                        .TrimStart()\n                        .Equals(\"Enabled\", StringComparison.InvariantCultureIgnoreCase);\n                    results.Add(new KeyValuePair<string, bool>(storedFeatureName, isEnabled));\n                    storedFeatureName = null;\n                }\n            }\n\n            return results;\n        }\n\n        private static string RunDismCommand(string command)\n        {\n            var psi = new ProcessStartInfo(DismFullPath, command)\n            {\n                UseShellExecute = false,\n                RedirectStandardOutput = true,","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/KlocTools/IO/DismTools.cs#L37-L73","documentation":"GetWindowsFeatures parses DISM's feature list line by line, expecting each \"Feature Name\" line to be followed by a \"State\" line. Encountering a \"State\" line with no stored feature name means the output structure diverged from the expected format, so parsing aborts with InvalidDataException.","triggerScenarios":"DISM output reformatted in a newer Windows build despite the /english flag; output localized differently; a feature block missing its name line; truncated DISM output.","commonSituations":"New Windows version changing DISM's list format; /english not honored by a particular build; DISM output partially captured.","solutions":["Ensure DISM is invoked with /english /format:list (the code already does this).","Update the parser to handle the new output format.","Run on a Windows build whose DISM output matches the parser's expectations."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return DismTools.GetWindowsFeatures(); }\ncatch (InvalidDataException) { /* report: could not enumerate Windows features */ }","preventionTips":["Pin to Windows builds whose DISM output matches the parser.","Log raw DISM output alongside the parse failure for diagnosis."],"tags":["dism","parsing","windows","external-process"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}