unoplatform/uno · error · FormatException

There is no type '{0}' in XAML namespace

Error message

There is no type '{0}' in XAML namespace

What it means

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.

Source

Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs:406

		}

		// XamlTypeName -> Type resolution

		static readonly int clr_ns_len = "clr-namespace:".Length;
		static readonly int clr_ass_len = "assembly=".Length;

		[UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "`Uno.UI.SourceGenerators/BindableTypeProviders` / `BindableMetadata.g.cs` ensures the type exists.")]
		Type ResolveXamlTypeName (string xmlNamespace, string xmlLocalName, IList<XamlType> typeArguments)
		{
			string ns = xmlNamespace;
			string name = xmlLocalName;

			if (ns == XamlLanguage.Xaml2006Namespace) {
				var xt = XamlLanguage.SpecialNames.Find (name, ns);
				if (xt == null)
					xt = XamlLanguage.AllTypes.FirstOrDefault (t => t.Name == xmlLocalName);
				if (xt == null)
					throw new FormatException (string.Format (CultureInfo.InvariantCulture, "There is no type '{0}' in XAML namespace", name));
				return xt.UnderlyingType;
			}
			else if (!ns.StartsWith ("clr-namespace:", StringComparison.Ordinal))
				return null;

			Type [] genArgs = null;
			if (typeArguments != null && typeArguments.Count > 0) {
				genArgs = (from t in typeArguments select t.UnderlyingType).ToArray ();
				if (genArgs.Any (t => t == null))
					return null;
			}

			// convert xml namespace to clr namespace and assembly
			string [] split = ns.Split (_semicolonArray);
			if (split.Length != 2 || split [0].Length < clr_ns_len || split [1].Length <= clr_ass_len)
				throw new XamlParseException (string.Format (CultureInfo.InvariantCulture, "Cannot resolve runtime namespace from XML namespace '{0}'", ns));
			string tns = split [0].Substring (clr_ns_len);
			string aname = split [1].Substring (clr_ass_len);

View on GitHub (pinned to 0418340488)

Solutions

  1. 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.).
  2. Fix the typo in the element/directive name.
  3. If the type is custom, move it out of the x: namespace into a clr-namespace mapping.

Example fix

<!-- before -->
<x:Strng>hi</x:Strng>
<!-- after -->
<x:String>hi</x:String>
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the name against known XAML language types before writing.
var known = XamlLanguage.AllTypes.FirstOrDefault(t => t.Name == name);
if (known == null && ns == XamlLanguage.Xaml2006Namespace)
    throw new FormatException($"'{name}' is not a valid XAML language type in the x: namespace.");

Try / catch

try { /* load/write XAML using x: namespace */ }
catch (FormatException ex) when (ex.Message.Contains("no type") && ex.Message.Contains("XAML namespace")) {
    // fix the misspelled x: element/directive name.
}

Prevention

When it happens

Trigger: Using a misspelled or nonexistent XAML-language construct, e.g. `<x:Strng>` instead of `<x:String>`, or referencing an invented intrinsic like `<x:Foo>`.

Common situations: Typos in x: elements/directives; assuming a type exists in the XAML vocabulary when it does not; copying snippets that use non-standard extensions.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/3221da247de02089. Report an issue: GitHub.