dotnet/wpf · error · NotImplementedException
NotImplementedException
Error message
NotImplementedException
What it means
IndexerPropertyInfo is an internal PropertyInfo wrapper used by WPF data binding to represent an indexer; SetValue is deliberately unsupported and always throws NotImplementedException. Values are written through binding-internal paths (DynamicIndexerAccessor), not through reflection SetValue.
Solutions
- Do not use this PropertyInfo for writes; set indexer values directly on the object: obj[key] = value.
- Filter out indexer properties before bulk-writing: skip PropertyInfo objects that are IndexerPropertyInfo or have IndexParameters.Length > 0.
- If generic reflection is needed, detect the type via the internal MS.Internal.Data.IndexerPropertyInfo type name and handle indexers specially.
Example fix
// before prop.SetValue(item, newValue, null); // NotImplementedException for indexer // after if (prop.GetIndexParameters().Length == 0) prop.SetValue(item, newValue, null);
Defensive patterns
Strategy: validation
Validate before calling
bool isWritable = prop != null && prop.GetIndexParameters().Length == 0;
Type guard
static bool IsRealProperty(System.Reflection.PropertyInfo p) => p.GetIndexParameters().Length == 0;
Try / catch
try { prop.SetValue(item, value, null); }
catch (NotImplementedException) { /* indexer write unsupported; set via obj[key] = value */ } Prevention
- Check GetIndexParameters().Length before using a PropertyInfo for read/write.
- Skip WPF's synthetic indexer (IndexerPropertyInfo) in generic reflection loops.
- Write indexer values directly through the object's this[] operator instead of reflection.
When it happens
Trigger: Any code calling SetValue on the IndexerPropertyInfo instance obtained via TypeDescriptor/reflection from ItemProperties — e.g. generic reflection-based serialization, property-grid code, or test code trying to assign to an indexer via this PropertyInfo.
Common situations: Using a reflection utility or ORM-ish code that enumerates ItemProperties of a bound item and attempts to write every property including the indexer.
Related errors
- Event not found: Event 'eventName' not found on type…
- new NotImplementedException()
- NotImplementedException
- SR.BamlReaderNoOwnerType
- SR.CollectionView_ViewTypeInsufficient
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/ffc76867120b4de4.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/IndexerPropertyInfo.cs:77
public override MethodInfo GetSetMethod(bool nonPublic)
{
return null;
}
public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, System.Globalization.CultureInfo culture)
{
// This is the only interesting line. GetValue returns the base object itself.
return obj;
}
public override Type PropertyType
{
get { return typeof(Object); }
}
public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
public override Type DeclaringType
{
get { throw new NotImplementedException(); }
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
throw new NotImplementedException();
}
public override object[] GetCustomAttributes(bool inherit)
{
throw new NotImplementedException();
}
public override bool IsDefined(Type attributeType, bool inherit)View on GitHub (pinned to 81131a70a4)