dotnet/wpf · error · XamlSchemaException
SR.BadXmlnsDefinition
Error message
SR.BadXmlnsDefinition
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/XmlNsInfo.cs:198 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/c1d969719dd8a33f.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/XmlNsInfo.cs:198
attributes = Attribute.GetCustomAttributes(assembly, typeof(XmlnsDefinitionAttribute));
foreach (Attribute attr in attributes)
{
XmlnsDefinitionAttribute xmlnsDefAttr = (XmlnsDefinitionAttribute)attr;
string xmlns = xmlnsDefAttr.XmlNamespace;
string clrns = xmlnsDefAttr.ClrNamespace;
LoadNsDefHelper(result, xmlns, clrns, assembly);
}
}
return result;
}
private void LoadNsDefHelper(IList<XmlNsDefinition> result, string xmlns, string clrns, Assembly assembly)
{
if (string.IsNullOrEmpty(xmlns) || clrns is null)
{
throw new XamlSchemaException(SR.Format(SR.BadXmlnsDefinition, assembly.FullName));
}
result.Add(new XmlNsDefinition { ClrNamespace = clrns, XmlNamespace = xmlns });
}
private ConcurrentDictionary<string, IList<string>> LoadClrToXmlNs()
{
ConcurrentDictionary<string, IList<string>> result =
XamlSchemaContext.CreateDictionary<string, IList<string>>();
Assembly assembly = Assembly;
if (assembly is null)
{
return result;
}
foreach (XmlNsDefinition nsDef in NsDefs)
{View on GitHub (pinned to 81131a70a4)