{"record":{"id":"860055e5723a7ae9","repo":"peass-ng/PEASS-ng","slug":"0-1-of-2-is-not-an-array-can-not-be-seriali","errorCode":null,"errorMessage":"{0} {1} of {2} is not an array. Can not be serialized as binary.","messagePattern":"(.+?) (.+?) of (.+?) is not an array\\. Can not be serialized as binary\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/ObjectMemberAccessor.cs","lineNumber":147,"sourceCode":"                accessor.SerializeMethod = YamlSerializeMethod.Never;\n                if ( mType.IsClass )\n                    accessor.SerializeMethod = YamlSerializeMethod.Content;\n            }\n            var attr1 = m.GetAttribute<YamlSerializeAttribute>();\n            if ( attr1 != null ) { // specified\n                if ( set == null ) { // read only member\n                    if ( attr1.SerializeMethod == YamlSerializeMethod.Assign ||\n                         ( mType.IsValueType && accessor.SerializeMethod == YamlSerializeMethod.Content ) )\n                        throw new ArgumentException(\"{0} {1} is not writeable by {2}.\"\n                            .DoFormat(mType.FullName, m.Name, attr1.SerializeMethod.ToString()));\n                }\n                accessor.SerializeMethod = attr1.SerializeMethod;\n            }\n            if ( accessor.SerializeMethod == YamlSerializeMethod.Never )\n                return; // no need to register\n            if ( accessor.SerializeMethod == YamlSerializeMethod.Binary ) {\n                if ( !mType.IsArray )\n                    throw new InvalidOperationException(\"{0} {1} of {2} is not an array. Can not be serialized as binary.\"\n                        .DoFormat(mType.FullName, m.Name, type.FullName));\n                if ( !TypeUtils.IsPureValueType(mType.GetElementType()) )\n                    throw new InvalidOperationException(\n                        \"{0} is not a pure ValueType. {1} {2} of {3} can not serialize as binary.\"\n                        .DoFormat(mType.GetElementType(), mType.FullName, m.Name, type.FullName));\n            }\n\n            // ShouldSerialize\n            //      YamlSerializeAttribute(Never) => false\n            //      ShouldSerializeSomeProperty => call it\n            //      DefaultValueAttribute(default) => compare to it\n            //      otherwise => true\n            var shouldSerialize = type.GetMethod(\"ShouldSerialize\" + m.Name,\n                System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic,\n                null, Type.EmptyTypes, new System.Reflection.ParameterModifier[0]);\n            if ( shouldSerialize != null && shouldSerialize.ReturnType == typeof(bool) && accessor.ShouldSeriealize == null )\n                accessor.ShouldSeriealize = obj => (bool)shouldSerialize.Invoke(obj, EmptyObjectArray);\n            var attr2 = m.GetAttribute<DefaultValueAttribute>();","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/ObjectMemberAccessor.cs#L129-L165","documentation":"ObjectMemberAccessor.RegisterMember validates Binary serialization requirements: YamlSerializeMethod.Binary is only supported for arrays whose element type is a pure (blittable, non-reference) value type. If the member type is not an array, RegisterMember throws InvalidOperationException('{0} {1} of {2} is not an array. Can not be serialized as binary.').","triggerScenarios":"Annotating a member of type List<T>, byte-like struct, or any non-array type with [YamlSerialize(YamlSerializeMethod.Binary)] and instantiating the accessor.","commonSituations":"Migrating members from byte[] to List<byte> while keeping the Binary attribute; applying Binary to multidimensional or jagged containers assumed to be arrays; copy-pasted attributes across members.","solutions":["Change the member type to a proper array (e.g. T[] or byte[]).","Change the attribute to a supported SerializeMethod (Content/Member) for non-array types.","Remove the Binary attribute and rely on default YAML serialization.","Keep a byte[] shadow property for binary serialization and map to/from the collection."],"exampleFix":"// before\n[YamlSerialize(YamlSerializeMethod.Binary)]\npublic List<byte> Data { get; set; } // not an array -> throws\n// after\n[YamlSerialize(YamlSerializeMethod.Binary)]\npublic byte[] Data { get; set; }","handlingStrategy":"type-guard","validationCode":"bool ok = mType.IsArray && TypeUtils.IsPureValueType(mType.GetElementType());","typeGuard":"static bool IsBinarySerializable(Type t) => t != null && t.IsArray && TypeUtils.IsPureValueType(t.GetElementType());","tryCatchPattern":"try { RegisterMember(m, set, get); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"not an array\")) { accessor.SerializeMethod = YamlSerializeMethod.Content; }","preventionTips":["Only mark T[] members with Binary method","Check element type purity (no reference-type fields) before Binary","Keep byte[] for binary payloads instead of List<byte>"],"tags":["csharp","yaml","serialization","arrays"],"backgroundTag":"binary-serialization-type-mismatch","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}