BCUninstaller/Bulk-Crap-Uninstaller · error · ArgumentOutOfRangeException
New value must be equal to or in between the minimum and max
Error message
New value must be equal to or in between the minimum and maximum values
What it means
Limited<T>.Value setter clamps the assigned value into the [Minimum, Maximum] range via GetLimitedValue. When ThrowOutOfRange is true, assigning a value greater than Maximum throws ArgumentOutOfRangeException (this branch) instead of clamping. With the default ThrowOutOfRange=false the value is silently capped to Maximum.
Source
Thrown at source/KlocTools/Limited.cs:39
/// Wrapped value, always equal to any of or in between Minimum and Maximum.
/// If ThrowOutOfRange if false and the value is assigned out of this range, it is trimmed.
/// Otherwise an exception is thrown.
/// </summary>
public T Value
{
get { return _value; }
set
{
_value = GetLimitedValue(value, Minimum, Maximum, ThrowOutOfRange);
}
}
private static Tvalue GetLimitedValue<Tvalue>(Tvalue value, Tvalue min, Tvalue max, bool throwOutOfRange)
where Tvalue : IComparable<Tvalue>
{
if (value.CompareTo(max) > 0)
{
if (throwOutOfRange) throw new ArgumentOutOfRangeException(nameof(value), @"New value must be equal to or in between the minimum and maximum values");
return max;
}
else if (value.CompareTo(min) < 0)
{
if (throwOutOfRange) throw new ArgumentOutOfRangeException(nameof(value), @"New value must be equal to or in between the minimum and maximum values");
return min;
}
return value;
}
/// <summary>
/// Minimal value of this variable. If set higher than the current value, the current value is trimmed up.
/// Must be lower than or equal to the maximal value.
/// </summary>
public T Minimum
{
get { return _minimum; }
setView on GitHub (pinned to 608321de98)
Solutions
- Clamp the value to the range before assigning it.
- Set ThrowOutOfRange=false if silent clamping is acceptable.
- Raise Maximum (or validate input) so the assigned value fits.
Example fix
// before limited.Value = x; // throws if x > Maximum // after limited.Value = Math.Min(x, limited.Maximum);
Defensive patterns
Strategy: validation
Validate before calling
if (x.CompareTo(limited.Maximum) > 0)
x = limited.Maximum;
limited.Value = x; Prevention
- Clamp inputs to [Minimum, Maximum] before assigning.
- Prefer ThrowOutOfRange=false for user-facing inputs where clamping is desired.
When it happens
Trigger: Assigning Value to something above Maximum while ThrowOutOfRange is true; a numeric control bound to a Limited<T> with throw-on-overflow enabled receiving a too-large input.
Common situations: UI bindings with throw-on-overflow; computed values that can exceed bounds; lowering Maximum without re-validating the current value.
Related errors
- Minimum value must be lower than or equal to the maximum val
- Pattern doesn't match the string. Sum of the pattern's parts
- Argument {argument} has already been defined
- {argument} has been specified more than once, expecting sing
- Font size must be higher than 0
AI-assisted analysis of BCUninstaller/Bulk-Crap-Uninstaller@608321de98 (2026-08-13).
Data as JSON: /api/errors/82f6a4fecea6fd34.
Report an issue: GitHub.