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
- Remove duplicates before reading the value.
- Use the multi-value indexer (this[argument]) instead of Single() when duplicates are expected.
- 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
- Deduplicate flag input before reading.
- Use the multi-value indexer when duplicates are legitimate.
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
- Argument {argument} has already been defined
- Pattern doesn't match the string. Sum of the pattern's parts
- New value must be equal to or in between the minimum and max
- Minimum value must be lower than or equal to the maximum val
- Font size must be higher than 0
AI-assisted analysis of BCUninstaller/Bulk-Crap-Uninstaller@608321de98 (2026-08-13).
Data as JSON: /api/errors/cc87ec8eee5caa73.
Report an issue: GitHub.