peass-ng/PEASS-ng · error · InvalidOperationException

Collection is readonly.

Error message

Collection is readonly.

What it means

A shared throw helper (ThrowReadOnlyError) used by the Add, Clear and Remove mutators of RehashableDictionary's read-only view: the wrapper object represents a read-only projection of the dictionary, so any state-changing operation is rejected with this InvalidOperationException before touching the underlying store.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/RehashableDictionary.cs:423

            {
                Dictionary.Added -= DictionaryChanged;
                Dictionary.Removed -= DictionaryChanged;
            }
            void DictionaryChanged(object sender, RehashableDictionary<K, V>.DictionaryEventArgs e)
            {
                Invalid = true;
            }

            protected void CheckValid()
            {
                if ( Invalid )
                    throw new InvalidOperationException(
                        "Dictionary was modified after this collection was created.");
            }

            static void ThrowReadOnlyError()
            {
                throw new InvalidOperationException("Collection is readonly.");
            }

            #region ICollection<K> メンバ

            public void Add(T item)
            { ThrowReadOnlyError(); }

            public void Clear()
            { ThrowReadOnlyError(); }

            public abstract bool Contains(T item);

            public abstract void CopyTo(T[] array, int arrayIndex);

            public virtual int Count
            { get { return Dictionary.Count; } }

            public bool IsReadOnly

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Mutate the underlying RehashableDictionary directly instead of its read-only view
  2. Create a writable copy (new dictionary from the view) if local mutation is needed
  3. Query IsReadOnly before calling mutators and skip/handle accordingly
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/RehashableDictionary.cs:423 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/d008dd3c088493a0. Report an issue: GitHub.