peass-ng/PEASS-ng · error · InvalidOperationException

{0} is not a pure ValueType. {1} {2} of {3} can not serializ

Error message

{0} is not a pure ValueType. {1} {2} of {3} can not serialize as binary.

What it means

A YamlSerializer member-registration guard in ObjectMemberAccessor.RegisterMember: a member is marked for binary serialization, but binary (raw) serialization in this library is only supported for pure value types; the resolved member type contains reference components, so the {0}=type name, {1}/{2}=member kind and name, {3}=declaring type are rejected. It fires when a YamlSerializeAttribute with binary method is applied to a reference-typed member.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/ObjectMemberAccessor.cs:150

            }
            var attr1 = m.GetAttribute<YamlSerializeAttribute>();
            if ( attr1 != null ) { // specified
                if ( set == null ) { // read only member
                    if ( attr1.SerializeMethod == YamlSerializeMethod.Assign ||
                         ( mType.IsValueType && accessor.SerializeMethod == YamlSerializeMethod.Content ) )
                        throw new ArgumentException("{0} {1} is not writeable by {2}."
                            .DoFormat(mType.FullName, m.Name, attr1.SerializeMethod.ToString()));
                }
                accessor.SerializeMethod = attr1.SerializeMethod;
            }
            if ( accessor.SerializeMethod == YamlSerializeMethod.Never )
                return; // no need to register
            if ( accessor.SerializeMethod == YamlSerializeMethod.Binary ) {
                if ( !mType.IsArray )
                    throw new InvalidOperationException("{0} {1} of {2} is not an array. Can not be serialized as binary."
                        .DoFormat(mType.FullName, m.Name, type.FullName));
                if ( !TypeUtils.IsPureValueType(mType.GetElementType()) )
                    throw new InvalidOperationException(
                        "{0} is not a pure ValueType. {1} {2} of {3} can not serialize as binary."
                        .DoFormat(mType.GetElementType(), mType.FullName, m.Name, type.FullName));
            }

            // ShouldSerialize
            //      YamlSerializeAttribute(Never) => false
            //      ShouldSerializeSomeProperty => call it
            //      DefaultValueAttribute(default) => compare to it
            //      otherwise => true
            var shouldSerialize = type.GetMethod("ShouldSerialize" + m.Name,
                System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic,
                null, Type.EmptyTypes, new System.Reflection.ParameterModifier[0]);
            if ( shouldSerialize != null && shouldSerialize.ReturnType == typeof(bool) && accessor.ShouldSeriealize == null )
                accessor.ShouldSeriealize = obj => (bool)shouldSerialize.Invoke(obj, EmptyObjectArray);
            var attr2 = m.GetAttribute<DefaultValueAttribute>();
            if ( attr2 != null && accessor.ShouldSeriealize == null ) {
                var defaultValue = attr2.Value;
                if ( TypeUtils.IsNumeric(defaultValue) && defaultValue.GetType() != mType )

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Change the member's YamlSerializeAttribute to a non-binary method (Assign/Content)
  2. Implement a type converter / serializer for the reference type instead of binary serialization
  3. Apply binary serialization only to blittable/pure value-type members
Defensive patterns

Strategy: validation

When it happens

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