{"record":{"id":"6cf5cb57c063bc7b","repo":"AvaloniaUI/Avalonia","slug":"unknown-binding-path-element-type-element-gettype","errorCode":null,"errorMessage":"Unknown binding path element type {element.GetType().FullName}","messagePattern":"Unknown binding path element type (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Data/CompiledBindingPath.cs","lineNumber":84,"sourceCode":"                        node = null;\n                        isRooted = true;\n                        break;\n                    case ElementNameElement name:\n                        node = new NamedElementNode(name.NameScope, name.Name);\n                        isRooted = true;\n                        break;\n                    case IStronglyTypedStreamElement stream:\n                        node = new StreamNode(stream.CreatePlugin());\n                        break;\n                    case ITypeCastElement typeCast:\n                        node = new FuncTransformNode(typeCast.Cast);\n                        break;\n                    case TemplatedParentPathElement:\n                        node = new TemplatedParentNode();\n                        isRooted = true;\n                        break;\n                    default:\n                        throw new InvalidOperationException($\"Unknown binding path element type {element.GetType().FullName}\");\n                }\n\n                if (node is not null)\n                    result.Add(node);\n            }\n\n\n            for (var i = 0; i < negated; ++i)\n                result.Add(new LogicalNotNode());\n        }\n\n        internal IEnumerable<ICompiledBindingPathElement> Elements => _elements;\n\n        /// <inheritdoc />\n        public override string ToString()\n            => string.Concat((IEnumerable<ICompiledBindingPathElement>)_elements);\n    }\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Data/CompiledBindingPath.cs#L66-L102","documentation":"Thrown as InvalidOperationException during CompiledBindingPath.Build when an ICompiledBindingPathElement in the path does not match any of the known element-type cases in the switch. Each path element must be a recognized type (PropertyElement, MethodAsDelegateElement, ArrayElementPathElement, stream/typecast/ancestor/name/self/templated-parent elements). An unknown element type indicates a version mismatch or an unsupported custom element injected into the path.","triggerScenarios":"A CompiledBindingPathBuilder accumulates an ICompiledBindingPathElement subclass that Build() does not handle. In normal use the builder only adds known element types, so this fires when custom/unsupported elements are injected, or when a newer path element type is fed to an older Avalonia build.","commonSituations":"Using reflection to add a custom ICompiledBindingPathElement to a CompiledBindingPathBuilder. Version mismatch: code compiled against a newer Avalonia adds an element type the runtime build cannot handle. Internal API misuse by a source generator or extension.","solutions":["Only use the public CompiledBindingPathBuilder methods (Property, Method, Command, Stream, etc.) to construct paths so all elements are recognized.","If on a custom/older Avalonia build, update to a version whose Build() switch handles your element type.","Do not inject custom ICompiledBindingPathElement implementations; extend the binding pipeline through supported extension points instead."],"exampleFix":"// before — custom element injected via reflection\nbuilder._elements.Add(new MyCustomElement());\npath.Build(); // throws: unknown element type\n// after — use a supported builder method\nbuilder.Property(propInfo, accessorFactory);","handlingStrategy":"validation","validationCode":"// Only use public CompiledBindingPathBuilder methods; do not inject custom elements.\n// If extending, ensure Build()'s switch handles your element type.","typeGuard":"static bool IsKnownElement(ICompiledBindingPathElement e) =>\n    e is PropertyElement or MethodAsDelegateElement or MethodAsCommandElement\n    or ArrayElementPathElement or VisualAncestorPathElement or AncestorPathElement\n    or SelfPathElement or ElementNameElement or IStronglyTypedStreamElement\n    or ITypeCastElement or TemplatedParentPathElement;","tryCatchPattern":"try { path.Build(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Unknown binding path element\"))\n{ /* remove unsupported custom element or upgrade Avalonia */ }","preventionTips":["Use only the public CompiledBindingPathBuilder methods to build paths.","Do not inject custom ICompiledBindingPathElement implementations.","Keep the Avalonia runtime version aligned with the code generator producing paths."],"tags":["compiled-binding","binding-path","internal","data"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}