dotnet/wpf · error · NotImplementedException
throw new NotImplementedException();
Error message
throw new NotImplementedException();
What it means
AttachedPropertyMethodSelector.BindToMethod is intentionally unimplemented — the class is only a method binder for attached-property method selection, so the Binder.BindToMethod override always throws NotImplementedException.
Solutions
- Do not call BindToMethod on this binder; use Binder.Default or DefaultBinder for method binding
- Restrict usage of AttachedPropertyMethodSelector to its SelectMethod capability
- Refactor the calling code to resolve MethodInfo via SelectMethod and invoke it directly
- If this surfaces from framework internals, file a WPF bug with the stack trace
Example fix
// before MethodBase m = attachedBinder.BindToMethod(bindingAttr, match, ref args, modifiers, culture, names, out state); // after MethodBase m = Type.DefaultBinder.BindToMethod(bindingAttr, match, ref args, modifiers, culture, names, out state);
Defensive patterns
Strategy: type-guard
Validate before calling
if (binder is AttachedPropertyMethodSelector)
throw new NotSupportedException("This binder supports SelectMethod only"); Type guard
bool SupportsBindToMethod(Binder b) => b is not AttachedPropertyMethodSelector;
Try / catch
try { return binder.BindToMethod(attr, match, ref args, mods, culture, names, out state); }
catch (NotImplementedException) { return Type.DefaultBinder.BindToMethod(attr, match, ref args, mods, culture, names, out state); } Prevention
- Treat AttachedPropertyMethodSelector as SelectMethod-only
- Fall back to Type.DefaultBinder for full bind semantics
- Document the binder's limited surface where it is passed around
When it happens
Trigger: Any call to BindToMethod on this binder, i.e. reflection/binding code that attempts to actually bind and invoke a method through WPF's attached-property method selector.
Common situations: Framework code or third-party code mistakenly routing generic member binding through this binder instead of the default binder; misuse of the Binder-derived class outside its intended SelectMethod role.
Related errors
- throw new AmbiguousMatchException();
- 0x80004001
- ArgumentException: path
- ArgumentException: relativeTo
- ArgumentNullException: path
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/171ecc5b2e9952e8.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ComponentModel/AttachedPropertyMethodSelector.cs:110
Type t = types[idx];
if (!t.IsAssignableFrom(p.ParameterType))
{
compat = false;
break;
}
}
return compat;
}
/// <summary>
/// We do not implement this.
/// </summary>
public override MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state)
{
// We are only a method binder.
throw new NotImplementedException();
}
/// <summary>
/// We do not implement this.
/// </summary>
public override FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo[] match, object value, CultureInfo culture)
{
// We are only a method binder.
throw new NotImplementedException();
}
/// <summary>
/// We do not implement this.
/// </summary>
public override object ChangeType(object value, Type type, CultureInfo culture)
{
// We are only a method binder.View on GitHub (pinned to 81131a70a4)