{"record":{"id":"25ad63e365a0a8b6","repo":"dotnet/wpf","slug":"sr-bamlreadernoownertype-0-1","errorCode":null,"errorMessage":"SR.BamlReaderNoOwnerType: {0} {1}","messagePattern":"SR\\.BamlReaderNoOwnerType: (.+?) (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlReader.cs","lineNumber":990,"sourceCode":"            BamlPropertyInfo info = new BamlPropertyInfo();\n\n            BamlAttributeInfoRecord attrInfo = SetCommonPropertyInfo(info,\n                ((BamlPropertyCustomRecord)_currentBamlRecord).AttributeId);\n            info.RecordType = _currentBamlRecord.RecordType;\n            info.AttributeUsage = BamlAttributeUsage.Default;\n\n            BamlPropertyCustomRecord bamlRecord = (BamlPropertyCustomRecord)_currentBamlRecord;\n\n            // Reverse the binary data stored in the record into a string by first getting the\n            // property.  If it has not already been cached in the attribute info record, then\n            // attempt to resolve it as a DependencyProperty or a PropertyInfo.\n            if (attrInfo.DP == null && attrInfo.PropInfo == null)\n            {\n                attrInfo.DP = MapTable.GetDependencyProperty(attrInfo);\n\n                if (attrInfo.OwnerType == null)\n                {\n                    throw new InvalidOperationException(SR.Format(SR.BamlReaderNoOwnerType, attrInfo.Name, AssemblyName));\n                }\n                if (attrInfo.DP == null)\n                {\n                    try\n                    {\n                        attrInfo.PropInfo = attrInfo.OwnerType.GetProperty(attrInfo.Name,\n                                BindingFlags.Instance | BindingFlags.Public);\n                    }\n                    catch (AmbiguousMatchException)\n                    {\n                        // Handle ambiguous match just like XamlTypeMapper.PropertyInfoFromName does.\n                        // This is for consistency, although it's probably wrong.\n                        // The doc for GetProperties says:\n                        //      The GetProperties method does not return properties\n                        //      in a particular order, such as alphabetical or\n                        //      declaration order. Your code must not depend on the\n                        //      order in which properties are returned, because that\n                        //      order varies.","sourceCodeStart":972,"sourceCodeEnd":1008,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlReader.cs#L972-L1008","documentation":"BamlReader.GetPropertyCustomRecordInfo throws this while resolving a custom property record in a BAML stream. It could not determine the OwnerType of the attribute, which is required to reflect over the property. Without an owner type neither a DependencyProperty nor a CLR PropertyInfo can be resolved from the BAML record, so the reader aborts with InvalidOperationException.","triggerScenarios":"Reading BAML (compiled XAML in a .baml resource) whose BamlAttributeInfoRecord has null DP and null PropInfo, MapTable.GetDependencyProperty returns null, and the attribute record's OwnerType is still null — i.e. the assembly or type owning the property could not be loaded/mapped.","commonSituations":"A referenced assembly containing the custom control or attached property is missing at runtime, a BAML stream produced by a mismatched/older compiler version references types not present, or XmlnsDefinition assembly mappings are broken so the owner type never gets set in the map table.","solutions":["Ensure the assembly that defines the property's owner type is deployed and referenced (check <Reference> entries and bin output).","Verify the xmlns prefix in the original XAML maps to the correct XmlnsDefinition/assembly; fix the mapping in AssemblyInfo.cs or the xmlns declaration.","Recompile the XAML/BAML with the current WPF SDK so attribute records carry correct owner type/assembly information.","If you own the reader path, check MapTable.GetDependencyProperty for early return and confirm AssemblyName matches the BAML source assembly."],"exampleFix":"// before (missing owner assembly)\n<Window xmlns:my=\"clr-namespace:MyControls\" />  // assembly not referenced\n\n// after\n<Window xmlns:my=\"clr-namespace:MyControls;assembly=MyControls\" />\n// and add <Reference Include=\"MyControls\" /> to the project","handlingStrategy":"validation","validationCode":"// before parsing BAML, confirm the owner types/properties resolve\nvar attrType = Assembly.Load(bamlAssemblyName).GetType(ownerTypeName, throwOnError: false);\nif (attrType == null)\n    throw new InvalidOperationException($\"Owner type '{ownerTypeName}' not loadable; BAML property '{attrName}' cannot be resolved.\");","typeGuard":"bool OwnerTypeResolves(BamlAttributeInfoRecord a) => a.OwnerType != null || a.DP != null || a.PropInfo != null;","tryCatchPattern":"try { reader.Read(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"owner\")) {\n    log.LogError(\"BAML attribute missing owner type — check assembly references and xmlns mappings.\");\n}","preventionTips":["Reference and deploy every assembly that defines types used in your XAML.","Keep clr-namespace/xmlns declarations aligned with XmlnsDefinition attributes.","Rebuild XAML projects after any control library API change.","Test BAML loading on a clean deployment (no dev-machine GAC reliance)."],"tags":["wpf","baml","reflection","xaml-parser"],"backgroundTag":"class-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"}