{"record":{"id":"a04a5ce9ee30ca4e","repo":"dotnet/wpf","slug":"sr-objectreaderattachedpropertynotfound","errorCode":null,"errorMessage":"SR.ObjectReaderAttachedPropertyNotFound","messagePattern":"SR\\.ObjectReaderAttachedPropertyNotFound","errorType":"exception","errorClass":"XamlObjectReaderException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs","lineNumber":1885,"sourceCode":"\n            private static void AddAttachedProperties(object value, ObjectMarkupInfo objectInfo, SerializerContext context)\n            {\n                var props = context.Runtime.GetAttachedProperties(value);\n                if (props is not null)\n                {\n                    foreach (var ap in props)\n                    {\n                        XamlType owningType = context.GetXamlType(ap.Key.DeclaringType);\n                        if (!owningType.IsVisibleTo(context.LocalAssembly))\n                        {\n                            continue;\n                        }\n\n                        XamlMember attachedProperty = owningType.GetAttachableMember(ap.Key.MemberName);\n\n                        if (attachedProperty is null)\n                        {\n                            throw new XamlObjectReaderException(SR.Format(SR.ObjectReaderAttachedPropertyNotFound, owningType, ap.Key.MemberName));\n                        }\n\n                        if (!CanPropertyXamlRoundtrip(attachedProperty, context))\n                        {\n                            continue;\n                        }\n\n                        var propertyInfo = MemberMarkupInfo.ForAttachedProperty(value, attachedProperty, ap.Value, context);\n                        if (propertyInfo is not null)\n                        {\n                            objectInfo.Properties.Add(propertyInfo);\n                        }\n                    }\n                }\n            }\n\n            private static ObjectMarkupInfo ForNull()\n            {","sourceCodeStart":1867,"sourceCodeEnd":1903,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs#L1867-L1903","documentation":"XamlObjectReader throws this when the object graph carries an attached-property record whose member cannot be resolved on the owning type: owningType.GetAttachableMember(memberName) returns null. The reader cannot map the recorded attached property name back to a real XamlMember.","triggerScenarios":"new XamlObjectReader(obj) where a serialized attached-property key (ap.Key.MemberName) names a member that does not exist (or is not an attachable member) on the owning type — typically after the defining class was renamed/removed or the name was recorded incorrectly.","commonSituations":"Referenced library upgraded and an attached property (e.g. custom Canvas-style attached property) renamed or deleted; custom attached properties registered via different names between write and read; typos in custom attached-property registration.","solutions":["Restore/keep the attached property's Get/Set accessor pair on the owning type with the original name","Update the recorded member name to the current attached-property name","Remove the stale attached-property entry from the object graph before reading","Re-register the attached property with DependencyProperty.RegisterAttached/ReadProperty so GetAttachableMember can find it"],"exampleFix":"// before: member removed after upgrade\n// after: restore accessors\npublic static double GetTilt(UIElement o) => (double)o.GetValue(TiltProperty);\npublic static void SetTilt(UIElement o, double v) => o.SetValue(TiltProperty, v);","handlingStrategy":"validation","validationCode":"foreach (var (owner, memberName) in attachedProps)\n    if (owner.GetAttachableMember == null /* via XamlType in your context: */ )\n        ; // resolve via schemaContext.GetXamlType(owner.GetType()).GetAttachableMember(memberName)\nvar xm = schemaContext.GetXamlType(ownerType)?.GetAttachableMember(memberName);\nif (xm == null) throw new InvalidOperationException($\"Unknown attached property {ownerType}.{memberName}\");","typeGuard":null,"tryCatchPattern":"try { using var r = new XamlObjectReader(obj); ... } catch (XamlObjectReaderException ex) when (ex.Message.Contains(\"AttachedPropertyNotFound\")) { /* prune or remap stale attached props */ }","preventionTips":["Keep Get/Set accessor names stable across refactors","Verify attached properties exist in the current assembly versions before reading","Strip unknown attached properties from graphs before round-trip"],"tags":["xaml","attached-property","schema"],"backgroundTag":"resource-not-found","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}