peass-ng/PEASS-ng · error · ArgumentOutOfRangeException

Failed to remove Trigger. Index out of range.

Error message

Failed to remove Trigger. Index out of range.

What it means

Bounds guard at the top of TriggerCollection.RemoveAt: it validates that index lies in [0, Count) before delegating to the native trigger-collection removal. Any negative index or index equal to/exceeding Count triggers it; callers like Remove, Insert, Clear and TriggerCollection itself reach it after resolving an Id or position.

Source

Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/TriggerCollection.cs:402

            if (idx != -1)
            {
                try
                {
                    RemoveAt(idx);
                    return true;
                }
                catch { }
            }
            return false;
        }

        /// <summary>Removes the trigger at a specified index.</summary>
        /// <param name="index">Index of trigger to remove.</param>
        /// <exception cref="ArgumentOutOfRangeException">Index out of range.</exception>
        public void RemoveAt(int index)
        {
            if (index < 0 || index >= Count)
                throw new ArgumentOutOfRangeException(nameof(index), index, @"Failed to remove Trigger. Index out of range.");
            var item = this[index].Clone();
            if (v2Coll != null)
                v2Coll.Remove(++index);
            else
                v1Task.DeleteTrigger((ushort)index); //Remove the trigger from the Task Scheduler
            if (!inV2set)
            {
                OnNotifyPropertyChanged(nameof(Count));
                OnNotifyPropertyChanged(IndexerName);
                CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));
            }
        }

        /// <summary>Copies the elements of the <see cref="TriggerCollection"/> to a new array.</summary>
        /// <returns>An array containing copies of the elements of the <see cref="TriggerCollection"/>.</returns>
        public Trigger[] ToArray()
        {
            var ret = new Trigger[Count];

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Validate 0 <= index < Count before calling RemoveAt
  2. Use Remove(Trigger) or the string-Id lookup instead of raw indices when the collection may have changed since the index was obtained
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/TriggerCollection.cs:402 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/23155358486bd028. Report an issue: GitHub.