peass-ng/PEASS-ng · error · RankException

Multi-dimensional arrays are not supported.

Error message

Multi-dimensional arrays are not supported.

What it means

ICollection.CopyTo(Array, int) explicitly rejects multi-dimensional target arrays by throwing RankException when array.Rank != 1. The guard exists because the Win32 Task Scheduler named-value storage is flat; copying into a 2D array has no meaningful mapping.

Source

Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/ActionCollection.cs:631

            if (Count > 1)
                return Properties.Resources.MultipleActions;
            return string.Empty;
        }

        void ICollection<Action>.Add(Action item) => Add(item);

        int IList.Add(object value)
        {
            Add((Action)value);
            return Count - 1;
        }

        bool IList.Contains(object value) => Contains((Action)value);

        void ICollection.CopyTo(Array array, int index)
        {
            if (array != null && array.Rank != 1)
                throw new RankException("Multi-dimensional arrays are not supported.");
            var src = new Action[Count];
            CopyTo(src, 0);
            Array.Copy(src, 0, array, index, Count);
        }

        IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

        System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() => null;

        int IList.IndexOf(object value) => IndexOf((Action)value);

        void IList.Insert(int index, object value) => Insert(index, (Action)value);

        void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement(XmlSerializationHelper.GetElementName(this), TaskDefinition.tns);
            Context = reader.GetAttribute("Context");
            while (reader.MoveToContent() == System.Xml.XmlNodeType.Element)

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Pass a one-dimensional Action[] (or Array) as the destination.
  2. Flatten any multi-dimensional array into a 1D array before calling CopyTo.
  3. Copy element-by-element with a foreach over the collection instead of using CopyTo.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/ActionCollection.cs:631 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/15edf5650cd08123. Report an issue: GitHub.