{"record":{"id":"3221da247de02089","repo":"unoplatform/uno","slug":"there-is-no-type-0-in-xaml-namespace","errorCode":null,"errorMessage":"There is no type '{0}' in XAML namespace","messagePattern":"There is no type '(.+?)' in XAML namespace","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs","lineNumber":406,"sourceCode":"\t\t}\n\n\t\t// XamlTypeName -> Type resolution\n\n\t\tstatic readonly int clr_ns_len = \"clr-namespace:\".Length;\n\t\tstatic readonly int clr_ass_len = \"assembly=\".Length;\n\n\t\t[UnconditionalSuppressMessage(\"Trimming\", \"IL3050\", Justification = \"`Uno.UI.SourceGenerators/BindableTypeProviders` / `BindableMetadata.g.cs` ensures the type exists.\")]\n\t\tType ResolveXamlTypeName (string xmlNamespace, string xmlLocalName, IList<XamlType> typeArguments)\n\t\t{\n\t\t\tstring ns = xmlNamespace;\n\t\t\tstring name = xmlLocalName;\n\n\t\t\tif (ns == XamlLanguage.Xaml2006Namespace) {\n\t\t\t\tvar xt = XamlLanguage.SpecialNames.Find (name, ns);\n\t\t\t\tif (xt == null)\n\t\t\t\t\txt = XamlLanguage.AllTypes.FirstOrDefault (t => t.Name == xmlLocalName);\n\t\t\t\tif (xt == null)\n\t\t\t\t\tthrow new FormatException (string.Format (CultureInfo.InvariantCulture, \"There is no type '{0}' in XAML namespace\", name));\n\t\t\t\treturn xt.UnderlyingType;\n\t\t\t}\n\t\t\telse if (!ns.StartsWith (\"clr-namespace:\", StringComparison.Ordinal))\n\t\t\t\treturn null;\n\n\t\t\tType [] genArgs = null;\n\t\t\tif (typeArguments != null && typeArguments.Count > 0) {\n\t\t\t\tgenArgs = (from t in typeArguments select t.UnderlyingType).ToArray ();\n\t\t\t\tif (genArgs.Any (t => t == null))\n\t\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// convert xml namespace to clr namespace and assembly\n\t\t\tstring [] split = ns.Split (_semicolonArray);\n\t\t\tif (split.Length != 2 || split [0].Length < clr_ns_len || split [1].Length <= clr_ass_len)\n\t\t\t\tthrow new XamlParseException (string.Format (CultureInfo.InvariantCulture, \"Cannot resolve runtime namespace from XML namespace '{0}'\", ns));\n\t\t\tstring tns = split [0].Substring (clr_ns_len);\n\t\t\tstring aname = split [1].Substring (clr_ass_len);","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs#L388-L424","documentation":"A FormatException (not XamlParseException) thrown by ResolveXamlTypeName when a name in the XAML 2006 ('x:') namespace is not found among XamlLanguage.SpecialNames or XamlLanguage.AllTypes. The XAML language vocabulary is closed; unknown names under x: are treated as format errors.","triggerScenarios":"Using a misspelled or nonexistent XAML-language construct, e.g. `<x:Strng>` instead of `<x:String>`, or referencing an invented intrinsic like `<x:Foo>`.","commonSituations":"Typos in x: elements/directives; assuming a type exists in the XAML vocabulary when it does not; copying snippets that use non-standard extensions.","solutions":["Verify the name against the XAML 2009/XAML 2006 vocabulary (x:String, x:Double, x:Int32, x:Array, x:Null, x:Static, x:Type, etc.).","Fix the typo in the element/directive name.","If the type is custom, move it out of the x: namespace into a clr-namespace mapping."],"exampleFix":"<!-- before -->\n<x:Strng>hi</x:Strng>\n<!-- after -->\n<x:String>hi</x:String>","handlingStrategy":"try-catch","validationCode":"// Validate the name against known XAML language types before writing.\nvar known = XamlLanguage.AllTypes.FirstOrDefault(t => t.Name == name);\nif (known == null && ns == XamlLanguage.Xaml2006Namespace)\n    throw new FormatException($\"'{name}' is not a valid XAML language type in the x: namespace.\");","typeGuard":null,"tryCatchPattern":"try { /* load/write XAML using x: namespace */ }\ncatch (FormatException ex) when (ex.Message.Contains(\"no type\") && ex.Message.Contains(\"XAML namespace\")) {\n    // fix the misspelled x: element/directive name.\n}","preventionTips":["Cross-check x: element names against the XAML vocabulary (x:String, x:Double, x:Null, x:Array, x:Static, x:Type, etc.).","Move custom types into a clr-namespace mapping, not the x: namespace.","Add a XAML validation/lint step to catch unknown x: members."],"tags":["xaml","type-resolution","xaml-language","schema-context"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}