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; }
            set

View on GitHub (pinned to 608321de98)

Solutions

  1. Clamp the value to the range before assigning it.
  2. Set ThrowOutOfRange=false if silent clamping is acceptable.
  3. 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

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


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