{"record":{"id":"3c372eed6171d1d2","repo":"unoplatform/uno","slug":"cannot-resolve-runtime-namespace-from-xml-namespac","errorCode":null,"errorMessage":"Cannot resolve runtime namespace from XML namespace '{0}'","messagePattern":"Cannot resolve runtime namespace from XML namespace '(.+?)'","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs","lineNumber":422,"sourceCode":"\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);\n\n\t\t\tstring taqn = GetTypeName (tns, name, genArgs);\n\t\t\tvar ass = OnAssemblyResolve (aname);\n\t\t\t// MarkupExtension type could omit \"Extension\" part in XML name.\n\t\t\tType ret = ass == null ? null : ass.GetType (taqn) ?? ass.GetType (GetTypeName (tns, name + \"Extension\", genArgs));\n\t\t\tif (ret == null)\n\t\t\t\tthrow new XamlParseException (string.Format (CultureInfo.InvariantCulture, \"Cannot resolve runtime type from XML namespace '{0}', local name '{1}' with {2} type arguments ({3})\", ns, name, typeArguments !=null ? typeArguments.Count : 0, taqn));\n\t\t\treturn genArgs == null ? ret : ret.MakeGenericType (genArgs);\n\t\t}\n\t\t\n\t\tstatic string GetTypeName (string tns, string name, Type [] genArgs)\n\t\t{\n\t\t\tstring tfn = tns.Length > 0 ? tns + '.' + name : name;\n\t\t\tif (genArgs != null)\n\t\t\t\ttfn += \"`\" + genArgs.Length;\n\t\t\treturn tfn;","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs#L404-L440","documentation":"A XamlParseException thrown by ResolveXamlTypeName when a clr-namespace style XML namespace is malformed. The URI must split into exactly two semicolon-delimited parts — 'clr-namespace:My.Ns' and 'assembly=MyAsm' — and both parts must be long enough. Any other shape (missing assembly segment, extra semicolons, empty parts) triggers this.","triggerScenarios":"Writing `xmlns:local=\"clr-namespace:My.Ns\"` without the `;assembly=...` segment, or `xmlns:local=\"clr-namespace:;assembly=\"`, or including an extra semicolon.","commonSituations":"Hand-authored clr-namespace URIs missing the assembly portion (common when porting from WPF where same-assembly refs sometimes omit it); assembly renamed so the URI is hand-edited incorrectly; copy-paste truncation.","solutions":["Use the full form: `clr-namespace:MyNamespace;assembly=MyAssembly`.","Verify the assembly name matches the compiled output assembly exactly (including case).","Avoid extra semicolons; the URI must contain exactly one ';' separating the two segments."],"exampleFix":"<!-- before -->\nxmlns:local=\"clr-namespace:MyApp.Controls\"\n<!-- after -->\nxmlns:local=\"clr-namespace:MyApp.Controls;assembly=MyApp\"","handlingStrategy":"validation","validationCode":"// Validate the clr-namespace URI shape before passing it to the schema context.\nconst string prefix = \"clr-namespace:\";\nif (ns != null && ns.StartsWith(prefix, StringComparison.Ordinal)) {\n    var parts = ns.Split(';');\n    if (parts.Length != 2 || parts[0].Length < prefix.Length || !parts[1].StartsWith(\"assembly=\"))\n        throw new FormatException($\"Malformed clr-namespace URI: '{ns}'. Expected 'clr-namespace:N.S;assembly=Asm'.\");\n}","typeGuard":null,"tryCatchPattern":"try { /* load/write XAML with clr-namespace mappings */ }\ncatch (XamlParseException ex) when (ex.Message.Contains(\"Cannot resolve runtime namespace\")) {\n    // fix the clr-namespace URI to include ';assembly=Name'.\n}","preventionTips":["Always use the full form 'clr-namespace:N.S;assembly=Asm'.","Verify the assembly name matches the compiled output exactly.","Ensure exactly one ';' separates the two segments — extra semicolons break parsing."],"tags":["xaml","namespace","clr-namespace","schema-context"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}