BCUninstaller/Bulk-Crap-Uninstaller · error · ArgumentException
Argument {argument} has already been defined
Error message
Argument {argument} has already been defined What it means
AddSingle enforces that an argument key appears exactly once. Calling it a second time for the same key (when the key already exists in _parameters) throws ArgumentException, since a single-value argument must not be defined more than once. Contrast with Add(), which allows multiple values per key.
Source
Thrown at source/KlocTools/IO/Arguments.cs:162
/// <summary>
/// Adds the specified argument.
/// </summary>
/// <param name="argument">The argument.</param>
/// <param name="value">The value.</param>
public void Add(string argument, string value)
{
if (!_parameters.ContainsKey(argument))
_parameters.Add(argument, new Collection<string>());
_parameters[argument].Add(value);
}
public void AddSingle(string argument, string value)
{
if (!_parameters.ContainsKey(argument))
_parameters.Add(argument, new Collection<string>());
else
throw new ArgumentException($"Argument {argument} has already been defined");
_parameters[argument].Add(value);
}
public void Remove(string argument)
{
if (_parameters.ContainsKey(argument))
_parameters.Remove(argument);
}
/// <summary>
/// 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)View on GitHub (pinned to 608321de98)
Solutions
- Use Add() instead of AddSingle() when multiple values are acceptable.
- Call Remove(argument) before AddSingle() to replace the value.
- Deduplicate the input before parsing it into the Arguments object.
Example fix
// before
args.AddSingle("mode", "a");
args.AddSingle("mode", "b"); // throws
// after
args.Remove("mode");
args.AddSingle("mode", "b"); Defensive patterns
Strategy: validation
Validate before calling
if (args.Exists(argument)) args.Remove(argument); args.AddSingle(argument, value);
Prevention
- Deduplicate input before parsing.
- Prefer Add() over AddSingle() when multiple values are valid.
When it happens
Trigger: Parsing CLI input where the same flag is provided twice and routed through AddSingle; a programmatic double-add of the same key.
Common situations: Duplicate flags in a script; two code paths adding the same argument; merged argument sources without dedup.
Related errors
- {argument} has been specified more than once, expecting sing
- 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/f947b934db835f10.
Report an issue: GitHub.