{"record":{"id":"059e1855d8de293b","repo":"peass-ng/PEASS-ng","slug":"failed-to-remove-action-index-out-of-range","errorCode":null,"errorMessage":"Failed to remove action. Index out of range.","messagePattern":"Failed to remove action\\. Index out of range\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/ActionCollection.cs","lineNumber":580,"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 action at a specified index.</summary>\n        /// <param name=\"index\">Index of action 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 action. Index out of range.\");\n            var item = this[index].Clone();\n            if (v2Coll != null)\n                v2Coll.Remove(++index);\n            else\n            {\n                v1Actions.RemoveAt(index);\n                SaveV1Actions();\n            }\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=\"ActionCollection\"/> to a new array.</summary>\n        /// <returns>An array containing copies of the elements of the <see cref=\"ActionCollection\"/>.</returns>","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/ActionCollection.cs#L562-L598","documentation":"RemoveAt throws ArgumentOutOfRangeException as a guard whenever the caller supplies an index outside the valid range [0, Count-1] of the ActionCollection. It fires before any COM call is made, so the index is the faulty input; callers like Remove use it defensively and swallow it to signal 'not found'.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/ActionCollection.cs:580 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the index against Count (e.g. if (idx >= 0 && idx < actions.Count)) before calling RemoveAt.","Use the collection's Remove(action) method instead, which locates the action and returns false rather than throwing when it is absent.","Wrap RemoveAt in try/catch (ArgumentOutOfRangeException) if absence is an acceptable outcome."],"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"}