{"record":{"id":"23155358486bd028","repo":"peass-ng/PEASS-ng","slug":"failed-to-remove-trigger-index-out-of-range","errorCode":null,"errorMessage":"Failed to remove Trigger. Index out of range.","messagePattern":"Failed to remove Trigger\\. Index out of range\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/TriggerCollection.cs","lineNumber":402,"sourceCode":"            if (idx != -1)\n            {\n                try\n                {\n                    RemoveAt(idx);\n                    return true;\n                }\n                catch { }\n            }\n            return false;\n        }\n\n        /// <summary>Removes the trigger at a specified index.</summary>\n        /// <param name=\"index\">Index of trigger to remove.</param>\n        /// <exception cref=\"ArgumentOutOfRangeException\">Index out of range.</exception>\n        public void RemoveAt(int index)\n        {\n            if (index < 0 || index >= Count)\n                throw new ArgumentOutOfRangeException(nameof(index), index, @\"Failed to remove Trigger. Index out of range.\");\n            var item = this[index].Clone();\n            if (v2Coll != null)\n                v2Coll.Remove(++index);\n            else\n                v1Task.DeleteTrigger((ushort)index); //Remove the trigger from the Task Scheduler\n            if (!inV2set)\n            {\n                OnNotifyPropertyChanged(nameof(Count));\n                OnNotifyPropertyChanged(IndexerName);\n                CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));\n            }\n        }\n\n        /// <summary>Copies the elements of the <see cref=\"TriggerCollection\"/> to a new array.</summary>\n        /// <returns>An array containing copies of the elements of the <see cref=\"TriggerCollection\"/>.</returns>\n        public Trigger[] ToArray()\n        {\n            var ret = new Trigger[Count];","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/TriggerCollection.cs#L384-L420","documentation":"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.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/TriggerCollection.cs:402 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate 0 <= index < Count before calling RemoveAt","Use Remove(Trigger) or the string-Id lookup instead of raw indices when the collection may have changed since the index was obtained"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}