{"record":{"id":"c1d969719dd8a33f","repo":"dotnet/wpf","slug":"sr-badxmlnsdefinition","errorCode":null,"errorMessage":"SR.BadXmlnsDefinition","messagePattern":"SR\\.BadXmlnsDefinition","errorType":"exception","errorClass":"XamlSchemaException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/XmlNsInfo.cs","lineNumber":198,"sourceCode":"                attributes = Attribute.GetCustomAttributes(assembly, typeof(XmlnsDefinitionAttribute));\n                foreach (Attribute attr in attributes)\n                {\n                    XmlnsDefinitionAttribute xmlnsDefAttr = (XmlnsDefinitionAttribute)attr;\n\n                    string xmlns = xmlnsDefAttr.XmlNamespace;\n                    string clrns = xmlnsDefAttr.ClrNamespace;\n                    LoadNsDefHelper(result, xmlns, clrns, assembly);\n                }\n            }\n\n            return result;\n        }\n\n        private void LoadNsDefHelper(IList<XmlNsDefinition> result, string xmlns, string clrns, Assembly assembly)\n        {\n            if (string.IsNullOrEmpty(xmlns) || clrns is null)\n            {\n                throw new XamlSchemaException(SR.Format(SR.BadXmlnsDefinition, assembly.FullName));\n            }\n\n            result.Add(new XmlNsDefinition { ClrNamespace = clrns, XmlNamespace = xmlns });\n        }\n\n        private ConcurrentDictionary<string, IList<string>> LoadClrToXmlNs()\n        {\n            ConcurrentDictionary<string, IList<string>> result =\n                XamlSchemaContext.CreateDictionary<string, IList<string>>();\n\n            Assembly assembly = Assembly;\n            if (assembly is null)\n            {\n                return result;\n            }\n\n            foreach (XmlNsDefinition nsDef in NsDefs)\n            {","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/XmlNsInfo.cs#L180-L216","documentation":"LoadNsDefHelper throws this XamlSchemaException when an XmlnsDefinitionAttribute read from an assembly carries invalid data — e.g. a null/empty XmlNamespace or ClrNamespace — so the xmlns definition cannot be registered while building the XAML namespace table.","triggerScenarios":"Thrown at src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/XmlNsInfo.cs:198 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the assembly contains a valid XmlnsDefinitionAttribute with non-empty XmlNamespace and ClrNamespace","Fix the [assembly: XmlnsDefinition(...)] declaration in the referenced assembly","Verify the assembly being scanned is a legitimate WPF/Silverlight assembly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}