dotnet/wpf · error · NotImplementedException
NotImplementedException
Error message
NotImplementedException
What it means
GetRegularDependencyProperty wraps a DependencyProperty-backed CLR property into a WpfXamlMember, but only when the base lookup returned a PropertyInfo. If the underlying member is not a PropertyInfo, the code has hit an unhandled case and throws a bare NotImplementedException — the internal assumption that DP-backed members are always properties was violated.
Solutions
- Ensure the type's DependencyProperty-backed members are exposed as real CLR wrapper properties.
- Check for a name clash: an event or method sharing the name of the DP wrapper is shadowing the property — rename it.
- If overriding LookupMember in a custom XamlType, return members whose UnderlyingMember is a PropertyInfo for DP-backed names.
- Catch NotImplementedException in tooling paths and fall back to base XamlType member resolution.
Example fix
// before
public event EventHandler Foo; // alongside public static readonly DependencyProperty FooProperty
// after
public static readonly DependencyProperty FooProperty = DependencyProperty.Register(nameof(Foo), ...);
public object Foo { get => GetValue(FooProperty); set => SetValue(FooProperty, value); } // CLR wrapper is a PropertyInfo Defensive patterns
Strategy: fallback
Validate before calling
var m = baseType.GetMember(name).FirstOrDefault(x => x is PropertyInfo);
if (m == null) throw new InvalidOperationException($"'{name}' on {baseType} is not a property; DP-backed members must be CLR properties."); Type guard
bool IsPropertyBacked(System.Reflection.MemberInfo mi) => mi is PropertyInfo;
Try / catch
try { member = wpfType.GetMember(name); }
catch (NotImplementedException)
{
// fall back to base XamlType.LookupMember or reflection-based resolution
} Prevention
- Always expose DP-backed members via CLR wrapper properties.
- Avoid name collisions between events/methods and DependencyProperty fields.
- When subclassing XamlType, return PropertyInfo-backed members for DP names.
When it happens
Trigger: LookupMember on a WpfXamlType resolves a DependencyProperty-backed name whose base XamlMember.UnderlyingMember is not a PropertyInfo (e.g. an event, a method, or a custom XamlMember returned by an overridden base lookup).
Common situations: Custom XAML schema extensions or third-party XamlType subclasses returning non-property underlying members for names that clash with DependencyProperty fields; dynamic-type scenarios where the member table contains unexpected member kinds.
Related errors
- ArgumentException: path
- ArgumentException: relativeTo
- ArgumentNullException: path
- ArgumentNullException: relativeTo
- NotImplementedException
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/629fb699bcc2d09e.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/Baml2006/WpfXamlType.cs:426
memberFromBase.Invoker.UnderlyingSetter,
SchemaContext, UseV3Rules);
}
return null;
}
private XamlMember GetRegularDependencyProperty(string name, DependencyProperty property, bool skipReadOnlyCheck)
{
XamlMember memberFromBase = base.LookupMember(name, skipReadOnlyCheck);
if (memberFromBase != null)
{
PropertyInfo propertyInfo = memberFromBase.UnderlyingMember as PropertyInfo;
if (propertyInfo != null)
{
return new WpfXamlMember(property, propertyInfo, SchemaContext, UseV3Rules);
}
else
{
throw new NotImplementedException();
}
}
return null;
}
// First try looking at the cache
// Then look to see if we have a known property on the type
private static XamlMember FindKnownMember(WpfXamlType wpfXamlType, string name, bool isAttachable)
{
XamlMember xamlMember = null;
// Look in the cache first
if (!isAttachable || wpfXamlType.IsBamlScenario)
{
if (wpfXamlType._members != null && wpfXamlType.Members.TryGetValue(name, out xamlMember))
{
return xamlMember;View on GitHub (pinned to 81131a70a4)