BCUninstaller/Bulk-Crap-Uninstaller · error · InvalidDataException

Dism output has invalid format

Error message

Dism output has invalid format

What it means

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.

Source

Thrown at source/KlocTools/IO/DismTools.cs:55

        /// Get a list of feature names and their status (true for enabled)
        /// </summary>
        public static IEnumerable<KeyValuePair<string, bool>> GetWindowsFeatures()
        {
            var output = RunDismCommand("/english /format:list /online /get-features");

            var results = new List<KeyValuePair<string, bool>>();
            string storedFeatureName = null;

            foreach (var line in output.Split(StringTools.NewLineChars.ToArray(), StringSplitOptions.RemoveEmptyEntries))
            {
                if (line.StartsWith("Feature Name", StringComparison.Ordinal))
                {
                    storedFeatureName = line.Substring(line.IndexOf(':') + 2);
                }
                else if (line.StartsWith("State", StringComparison.Ordinal))
                {
                    if (storedFeatureName == null)
                        throw new InvalidDataException("Dism output has invalid format");

                    var isEnabled = line.Substring(line.IndexOf(':') + 1)
                        .TrimStart()
                        .Equals("Enabled", StringComparison.InvariantCultureIgnoreCase);
                    results.Add(new KeyValuePair<string, bool>(storedFeatureName, isEnabled));
                    storedFeatureName = null;
                }
            }

            return results;
        }

        private static string RunDismCommand(string command)
        {
            var psi = new ProcessStartInfo(DismFullPath, command)
            {
                UseShellExecute = false,
                RedirectStandardOutput = true,

View on GitHub (pinned to 608321de98)

Solutions

  1. Ensure DISM is invoked with /english /format:list (the code already does this).
  2. Update the parser to handle the new output format.
  3. Run on a Windows build whose DISM output matches the parser's expectations.
Defensive patterns

Strategy: try-catch

Try / catch

try { return DismTools.GetWindowsFeatures(); }
catch (InvalidDataException) { /* report: could not enumerate Windows features */ }

Prevention

When it happens

Trigger: 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.

Common situations: New Windows version changing DISM's list format; /english not honored by a particular build; DISM output partially captured.

Related errors


AI-assisted analysis of BCUninstaller/Bulk-Crap-Uninstaller@608321de98 (2026-08-13). Data as JSON: /api/errors/8a7bba63a6f02271. Report an issue: GitHub.