{"record":{"id":"2f5e175e6be69f50","repo":"peass-ng/PEASS-ng","slug":"xml-element-name-does-not-match-object","errorCode":null,"errorMessage":"XML element name does not match object.","messagePattern":"XML element name does not match object\\.","errorType":"exception","errorClass":"XmlException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/XmlSerializationHelper.cs","lineNumber":491,"sourceCode":"        }\n\n        public static void ReadObject([NotNull] XmlReader reader, [NotNull] object obj, PropertyConversionHandler handler = null)\n        {\n            if (obj == null)\n                throw new ArgumentNullException(nameof(obj));\n\n            reader.MoveToContent();\n\n            if (obj is IXmlSerializable)\n            {\n                ((IXmlSerializable)obj).ReadXml(reader);\n            }\n            else\n            {\n                object oVal = null;\n                string oName = GetAttributeValue(obj.GetType(), typeof(XmlRootAttribute), \"ElementName\", true, ref oVal) ? oVal.ToString() : obj.GetType().Name;\n                if (reader.LocalName != oName)\n                    throw new XmlException(\"XML element name does not match object.\");\n\n                if (!reader.IsEmptyElement)\n                {\n                    reader.ReadStartElement();\n                    reader.MoveToContent();\n                    ReadObjectProperties(reader, obj, handler);\n                    reader.ReadEndElement();\n                }\n                else\n                    reader.Skip();\n            }\n        }\n\n        public static void ReadObjectFromXmlText([NotNull] string xml, [NotNull] object obj, PropertyConversionHandler handler = null)\n        {\n            using (System.IO.StringReader sr = new System.IO.StringReader(xml))\n            {\n                using (XmlReader reader = XmlReader.Create(sr))","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/XmlSerializationHelper.cs#L473-L509","documentation":"Structural-consistency guard in ReadObject during XML deserialization: the library compares the current XML element's name against the object's expected root element name (from XmlRootAttribute.ElementName or the type name). A mismatch means the XML stream does not describe this object type — the XML was written for a different schema/class — so deserialization is aborted with ArgumentException rather than silently mis-binding properties.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/XmlSerializationHelper.cs:491 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the XML element name matches the type's XmlRootAttribute ElementName, or annotate the class with the correct XmlRoot attribute","Deserialize into the same class type that produced the XML, or use ReadObjectFromXmlText with the matching type"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}