unoplatform/uno · error · InvalidOperationException
Type '{0}' is not resolved as a valid type by the type resol
Error message
Type '{0}' is not resolved as a valid type by the type resolver '{1}'. What it means
Thrown by TypeExtension.ProvideValue when the IXamlTypeResolver.Resolve(TypeName) call returns null, meaning the resolver could not map the type name string to any loaded Type. The message interpolates both the offending TypeName and the resolver's concrete type to aid diagnosis.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Windows.Markup/TypeExtension.cs:93
{
throw new InvalidOperationException ("Either TypeName or Type must be filled before calling ProvideValue method");
}
if (serviceProvider == null) // it can be null when Type is supplied.
{
throw new ArgumentNullException ("serviceProvider");
}
var p = serviceProvider.GetService (typeof (IXamlTypeResolver)) as IXamlTypeResolver;
if (p == null)
{
throw new InvalidOperationException ("serviceProvider does not provide IXamlTypeResolver service.");
}
var ret = p.Resolve (TypeName);
if (ret == null)
{
throw new InvalidOperationException (String.Format (CultureInfo.InvariantCulture, "Type '{0}' is not resolved as a valid type by the type resolver '{1}'.", TypeName, p.GetType ()));
}
return ret;
}
}
}
View on GitHub (pinned to 0418340488)
Solutions
- Declare the xmlns prefix at the root element, e.g. xmlns:local="using:MyApp.Controls".
- Confirm the target type exists in a referenced assembly and the namespace matches.
- Use assembly-qualified names if the type lives in a differently named assembly.
- Check for typos and that the type is public (internal types need InternalsVisibleTo or the XAML schema context must allow internals).
Example fix
<!-- before --> <x:Type TypeName="local:MyControl"/> <!-- local prefix not declared --> <!-- after --> <Page xmlns:local="using:MyApp.Controls"> <x:Type TypeName="local:MyControl"/> </Page>
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-resolve the type name to give a clearer error
var resolver = (IXamlTypeResolver)sp.GetService(typeof(IXamlTypeResolver));
if (resolver.Resolve(typeName) == null)
throw new InvalidOperationException($"Type '{typeName}' not resolvable");
var value = new TypeExtension { TypeName = typeName }.ProvideValue(sp); Type guard
static bool IsTypeNameResolvable(IXamlTypeResolver r, string name)
=> r?.Resolve(name) != null; Try / catch
try
{
var t = (Type)new TypeExtension { TypeName = name }.ProvideValue(ctx);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("is not resolved as a valid type"))
{
// log xmlns/assembly issue and fall back to Type.GetType(name)
t = Type.GetType(name);
} Prevention
- Declare every xmlns prefix used in x:Type directives at the root element.
- Keep type names stable across versions or update XAML when renaming.
- Ensure referenced assemblies are loaded at runtime (especially under trimming/AOT).
When it happens
Trigger: TypeName references an unknown CLR namespace, a missing xmlns prefix, an assembly that is not loaded, or a typo in the type name. Resolve returns null instead of throwing, so ProvideValue surfaces the failure here.
Common situations: XAML with an undeclared xmlns prefix (e.g. local: used without xmlns:local=); type moved or renamed between versions; assembly not referenced at runtime; namespace mismatch between XAML and code-behind.
Related errors
- typeName
- type
- Either TypeName or Type must be filled before calling Provid
- serviceProvider
- serviceProvider does not provide IXamlTypeResolver service.
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/5011c9bf99d3a961.
Report an issue: GitHub.