peass-ng/PEASS-ng · error · ArgumentException
Items in collection exceed available items in destination ar
Error message
Items in collection exceed available items in destination array.
What it means
ICollection<NameValuePair>.CopyTo throws ArgumentException when the destination array cannot hold all items: array.Length - arrayIndex is smaller than the v2 collection count. The fault is in the caller's sizing/offset of the destination array, not in the collection contents.
Source
Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/NamedValueCollection.cs:540
bool ICollection<NameValuePair>.Contains(NameValuePair item)
{
if (v2Coll == null)
return unboundDict.Contains(item);
foreach (var invp in this)
if (Equals(item, invp)) return true;
return false;
}
void ICollection<NameValuePair>.CopyTo(NameValuePair[] array, int arrayIndex)
{
if (v2Coll == null)
unboundDict.CopyTo(array, arrayIndex);
else
{
if (array.Length - arrayIndex < v2Coll.Count)
throw new ArgumentException("Items in collection exceed available items in destination array.");
if (arrayIndex < 0)
throw new ArgumentException(@"Array index must be 0 or greater.", nameof(arrayIndex));
for (var i = 0; i < v2Coll.Count; i++)
array[i + arrayIndex] = new NameValuePair(v2Coll[i]);
}
}
bool ICollection<NameValuePair>.IsReadOnly => false;
ICollection<string> IDictionary<string, string>.Keys => Names;
bool ICollection<KeyValuePair<string, string>>.IsReadOnly => false;
bool ICollection<NameValuePair>.Remove(NameValuePair item)
{
var i = -1;
try
{View on GitHub (pinned to 53fb989abc)
Solutions
- Allocate the destination array with at least Count + arrayIndex elements.
- Use arrayIndex 0 with an array sized to Count for a simple full copy.
- Use LINQ ToArray() instead of CopyTo to let the runtime size the array.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/NamedValueCollection.cs:540 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/3c783a9265dfa1b5.
Report an issue: GitHub.