unoplatform/uno · error · InvalidOperationException
The type '{fullyQualifiedMetadataName}' is not found.
Error message
The type '{fullyQualifiedMetadataName}' is not found. What it means
GetRequiredTypeByMetadataName resolves a fully-qualified type (RoutedEventArgs, BringIntoViewRequestedEventArgs, etc.) via compilation.GetTypeByMetadataName and throws InvalidOperationException if it returns null. A null return means the type is absent from the compilation — its declaring assembly is not referenced, or the metadata name constant is wrong.
Source
Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/ImplementedRoutedEvents/ImplementedRoutedEventsGenerator.cs:118
_events.Add("OnPreviewKeyUp", keyRoutedEventArgs);
_events.Add("OnKeyDown", keyRoutedEventArgs);
_events.Add("OnKeyUp", keyRoutedEventArgs);
var characterReceivedRoutedEventArgs = GetRequiredTypeByMetadataName(XamlConstants.Types.CharacterReceivedRoutedEventArgs);
_events.Add("OnCharacterReceived", characterReceivedRoutedEventArgs);
var routedEventArgs = GetRequiredTypeByMetadataName(XamlConstants.Types.RoutedEventArgs);
_events.Add("OnLostFocus", routedEventArgs);
_events.Add("OnGotFocus", routedEventArgs);
var bringIntoViewRequestedEventArgs = GetRequiredTypeByMetadataName(XamlConstants.Types.BringIntoViewRequestedEventArgs);
_events.Add("OnBringIntoViewRequested", bringIntoViewRequestedEventArgs);
}
private INamedTypeSymbol GetRequiredTypeByMetadataName(string fullyQualifiedMetadataName)
{
var type = _context.Compilation.GetTypeByMetadataName(fullyQualifiedMetadataName);
return type ?? throw new InvalidOperationException($"The type '{fullyQualifiedMetadataName}' is not found.");
}
public override void VisitModule(IModuleSymbol symbol) => VisitNamespace(symbol.GlobalNamespace);
public override void VisitNamedType(INamedTypeSymbol symbol)
{
foreach (var type in symbol.GetTypeMembers())
{
VisitNamedType(type);
}
ProcessType(symbol);
}
public override void VisitNamespace(INamespaceSymbol symbol)
{
foreach (var n in symbol.GetNamespaceMembers())
{View on GitHub (pinned to 0418340488)
Solutions
- Add/restore the PackageReference or ProjectReference that provides the missing type (e.g. Microsoft.UI.Xaml / the Uno Microsoft.UI package).
- Check the reported metadata name against the current Uno/WinUI version in case it was renamed.
- Run dotnet restore and rebuild to re-resolve references.
Example fix
<!-- before: Microsoft.UI.Xaml not referenced --> <!-- after --> <ItemGroup> <PackageReference Include="Microsoft.UI.Xaml" Version="..." /> </ItemGroup>
Defensive patterns
Strategy: validation
Validate before calling
// Before building, confirm the routed-event-arg types resolve in the compilation
var names = new[] { "Microsoft.UI.Xaml.RoutedEventArgs", "Microsoft.UI.Xaml.BringIntoViewRequestedEventArgs" };
foreach (var n in names)
if (Type.GetType(n) == null) Console.WriteLine($"WARN: {n} not found; add the Microsoft.UI.Xaml reference."); Prevention
- Keep the Microsoft.UI.Xaml / Uno Microsoft.UI reference present in projects that use XAML routed events.
- After dependency upgrades, verify type names against the current version.
When it happens
Trigger: The generator requests a routed-event-arg type that is not present in the compilation, e.g. Microsoft.UI.Xaml.RoutedEventArgs when the Microsoft.UI.Xaml reference is missing.
Common situations: Building a project that lacks the Microsoft.UI.Xaml reference; after a namespace/type rename in a dependency; mismatched Uno SDK version where the type moved.
Related errors
- Unable to resolve {symbol} (Reason: {errorTypeSymbol.Candida
- No valid setter found for attached property {name}
- Unable to find type {fullName}
- Expected event to start with 'On'
- The type {0} could not be found
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/8a7e3d635ad2abc7.
Report an issue: GitHub.