peass-ng/PEASS-ng · error · InvalidOperationException
Can't get instance of {pi.PropertyType.Name}.
Error message
Can't get instance of {pi.PropertyType.Name}. What it means
Reflection-fallback sentinel in ReadObjectProperties during XML deserialization: while populating a collection property, neither an Add(object) nor a strongly-typed Add(elementType) method could be found or successfully invoked on the property's type, so the library cannot build an instance of the property type from the XML and throws with the property type name substituted into the message. The faulting input is the XML being deserialized onto an object whose collection property lacks a usable Add method.
Source
Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/XmlSerializationHelper.cs:463
{
var mi = pi.PropertyType.GetMethod("Add", new Type[] { typeof(object) });
if (mi != null)
try { foreach (var i in par) mi.Invoke(pi.GetValue(obj, null), new object[] { i }); done = true; } catch { }
}
if (!done && et != typeof(Object))
{
var mi = pi.PropertyType.GetMethod("Add", new Type[] { et });
if (mi != null)
try { foreach (var i in par) mi.Invoke(pi.GetValue(obj, null), new object[] { i }); done = true; } catch { }
}
// Throw error if not done
}
}
else
{
object inst = pi.GetValue(obj, null) ?? Activator.CreateInstance(pi.PropertyType);
if (inst == null)
throw new InvalidOperationException($"Can't get instance of {pi.PropertyType.Name}.");
ReadObject(reader, inst, handler);
}
}
else
{
reader.Skip();
reader.MoveToContent();
}
}
}
public static void ReadObject([NotNull] XmlReader reader, [NotNull] object obj, PropertyConversionHandler handler = null)
{
if (obj == null)
throw new ArgumentNullException(nameof(obj));
reader.MoveToContent();
View on GitHub (pinned to 53fb989abc)
Solutions
- Ensure the target property's type exposes a public Add method compatible with the element type (e.g. List<T> or a custom collection implementing Add)
- Add a parameterless constructor and IXmlSerializable implementation to the property type so the deserializer can build it directly
- Fix or regenerate the XML so it matches the expected object schema for that property
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/XmlSerializationHelper.cs:463 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/d67ff2a7f2dea8f1.
Report an issue: GitHub.