{"record":{"id":"171ecc5b2e9952e8","repo":"dotnet/wpf","slug":"throw-new-notimplementedexception-171ecc","errorCode":null,"errorMessage":"throw new NotImplementedException();","messagePattern":"throw new NotImplementedException\\(\\);","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ComponentModel/AttachedPropertyMethodSelector.cs","lineNumber":110,"sourceCode":"                Type t = types[idx];\n\n                if (!t.IsAssignableFrom(p.ParameterType))\n                {\n                    compat = false;\n                    break;\n                }\n            }\n\n            return compat;\n        }\n\n        /// <summary>\n        ///     We do not implement this.\n        /// </summary>\n        public override MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state)\n        {\n            // We are only a method binder.\n            throw new NotImplementedException();\n        }\n\n        /// <summary>\n        ///     We do not implement this.\n        /// </summary>\n        public override FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo[] match, object value, CultureInfo culture) \n        {\n            // We are only a method binder.\n            throw new NotImplementedException();\n        }\n\n\n        /// <summary>\n        ///     We do not implement this.\n        /// </summary>\n        public override object ChangeType(object value, Type type, CultureInfo culture)\n        {\n            // We are only a method binder.","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ComponentModel/AttachedPropertyMethodSelector.cs#L92-L128","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nMethodBase m = attachedBinder.BindToMethod(bindingAttr, match, ref args, modifiers, culture, names, out state);\n// after\nMethodBase m = Type.DefaultBinder.BindToMethod(bindingAttr, match, ref args, modifiers, culture, names, out state);","handlingStrategy":"type-guard","validationCode":"if (binder is AttachedPropertyMethodSelector)\n    throw new NotSupportedException(\"This binder supports SelectMethod only\");","typeGuard":"bool SupportsBindToMethod(Binder b) => b is not AttachedPropertyMethodSelector;","tryCatchPattern":"try { return binder.BindToMethod(attr, match, ref args, mods, culture, names, out state); }\ncatch (NotImplementedException) { return Type.DefaultBinder.BindToMethod(attr, match, ref args, mods, culture, names, out state); }","preventionTips":["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"],"tags":["wpf","reflection","binder","not-implemented"],"backgroundTag":"method-not-implemented","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}