BCUninstaller/Bulk-Crap-Uninstaller · error · ArgumentException

{argument} has been specified more than once, expecting sing

Error message

{argument} has been specified more than once, expecting single value

What it means

AssertSingle is called by IsTrue() and Single() to guard against ambiguous reads. If an argument was added more than once (via Add()), reading it as a single value throws ArgumentException because the intended value is ambiguous. The message names the offending argument.

Source

Thrown at source/KlocTools/IO/Arguments.cs:192

        /// Determines whether the specified argument is true.
        /// </summary>
        /// <param name="argument">The argument.</param>
        /// <returns>
        ///     <c>true</c> if the specified argument is true; otherwise, <c>false</c>.
        /// </returns>
        public bool IsTrue(string argument)
        {
            AssertSingle(argument);

            var arg = this[argument];

            return arg != null && arg[0].Equals("true", StringComparison.OrdinalIgnoreCase);
        }

        private void AssertSingle(string argument)
        {
            if (this[argument] != null && this[argument].Count > 1)
                throw new ArgumentException($"{argument} has been specified more than once, expecting single value");
        }

        public string Single(string argument)
        {
            AssertSingle(argument);

            //only return value if its NOT true, there is only a single item for that argument
            //and the argument is defined
            if (this[argument] != null && !IsTrue(argument))
                return this[argument][0];

            return null;
        }

        public bool Exists(string argument)
        {
            return (this[argument] != null && this[argument].Count > 0);
        }

View on GitHub (pinned to 608321de98)

Solutions

  1. Remove duplicates before reading the value.
  2. Use the multi-value indexer (this[argument]) instead of Single() when duplicates are expected.
  3. Validate per-argument counts during parsing and reject/normalize early.

Example fix

// before
string v = args.Single("file"); // throws if --file given twice
// after
var list = args["file"];
string v = list != null ? list[0] : null;
Defensive patterns

Strategy: validation

Validate before calling

var list = args[argument];
if (list != null && list.Count > 1)
    /* pick a value or reject rather than calling Single/IsTrue */

Prevention

When it happens

Trigger: Input with repeated flags that is then read via Single() or IsTrue(); switch flags accidentally duplicated by quoting in a script.

Common situations: A script passing /flag twice; argument sources merged without dedup; a toggle flag repeated.

Related errors


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