peass-ng/PEASS-ng · error · XmlException
XML element name does not match object.
Error message
XML element name does not match object.
What it means
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.
Source
Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/XmlSerializationHelper.cs:491
}
public static void ReadObject([NotNull] XmlReader reader, [NotNull] object obj, PropertyConversionHandler handler = null)
{
if (obj == null)
throw new ArgumentNullException(nameof(obj));
reader.MoveToContent();
if (obj is IXmlSerializable)
{
((IXmlSerializable)obj).ReadXml(reader);
}
else
{
object oVal = null;
string oName = GetAttributeValue(obj.GetType(), typeof(XmlRootAttribute), "ElementName", true, ref oVal) ? oVal.ToString() : obj.GetType().Name;
if (reader.LocalName != oName)
throw new XmlException("XML element name does not match object.");
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
reader.MoveToContent();
ReadObjectProperties(reader, obj, handler);
reader.ReadEndElement();
}
else
reader.Skip();
}
}
public static void ReadObjectFromXmlText([NotNull] string xml, [NotNull] object obj, PropertyConversionHandler handler = null)
{
using (System.IO.StringReader sr = new System.IO.StringReader(xml))
{
using (XmlReader reader = XmlReader.Create(sr))View on GitHub (pinned to 53fb989abc)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/XmlSerializationHelper.cs:491 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/2f5e175e6be69f50.
Report an issue: GitHub.