unoplatform/uno · error · InvalidOperationException
Unable to find type {fullyQualifiedName}
Error message
Unable to find type {fullyQualifiedName} What it means
Thrown (lazily) by GetMandatorySymbolAsLazy when Compilation.GetTypeByMetadataName returns null for a type that the XAML generator considers mandatory — including Border, SolidColorBrush, RowDefinition, ColumnDefinition, and System.Threading.Tasks.Task. The Lazy is only evaluated when the symbol is first accessed.
Source
Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs:375
WindowSymbol = GetOptionalSymbolAsLazy(XamlConstants.Types.Window);
ApplicationSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.Application);
ResourceDictionarySymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.ResourceDictionary);
TextBlockSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.TextBlock);
RunSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.Run);
SpanSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.Span);
BorderSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.Border);
SolidColorBrushSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.SolidColorBrush);
RowDefinitionSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.RowDefinition);
ColumnDefinitionSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.ColumnDefinition);
TaskSymbol = GetMandatorySymbolAsLazy("System.Threading.Tasks");
TypeProviders = ImmutableArray.Create<ITypeProvider>(
new MvvmTypeProvider(this)
);
}
private Lazy<INamedTypeSymbol> GetMandatorySymbolAsLazy(string fullyQualifiedName)
=> new(() => _generatorContext.Compilation.GetTypeByMetadataName(fullyQualifiedName) ?? throw new InvalidOperationException($"Unable to find type {fullyQualifiedName}"));
internal Lazy<INamedTypeSymbol?> GetOptionalSymbolAsLazy(string fullyQualifiedName)
=> new(() => _generatorContext.Compilation.GetTypeByMetadataName(fullyQualifiedName));
private Lazy<INamedTypeSymbol> GetSpecialTypeSymbolAsLazy(SpecialType specialType)
=> new(() => _generatorContext.Compilation.GetSpecialType(specialType));
private static bool IsWinUIItem(Uno.Roslyn.MSBuildItem item)
=> item.GetMetadataValue("XamlRuntime") is { } xamlRuntime
? xamlRuntime == "WinUI" || string.IsNullOrWhiteSpace(xamlRuntime)
: true;
private IEnumerable<Uno.Roslyn.MSBuildItem> GetWinUIItems(string name)
=> _generatorContext.GetMSBuildItemsWithAdditionalFiles(name).Where(IsWinUIItem);
/// <summary>
/// Get the file location as seen in the IDE, used for ResourceDictionary.Source resolution.
/// </summary>View on GitHub (pinned to 0418340488)
Solutions
- Verify that the project references the correct Uno.UI (and related) NuGet packages with compatible versions.
- Run dotnet restore to ensure all packages are properly restored.
- Check for version mismatches between Uno.UI, Uno.WinUI, and the target framework packages.
- If the error names a specific type, ensure the assembly defining that type is referenced.
Example fix
<!-- Ensure correct package references in .csproj --> <ItemGroup> <PackageReference Include="Uno.UI" Version="5.x.x" /> <PackageReference Include="Uno.WinUI" Version="5.x.x" /> </ItemGroup>
Defensive patterns
Strategy: validation
Validate before calling
<!-- Verify mandatory type-providing packages are referenced --> <ItemGroup> <PackageReference Include="Uno.WinUI" Version="$(UnoVersion)" /> <PackageReference Include="Uno.UI" Version="$(UnoVersion)" /> </ItemGroup> <!-- After editing, run: dotnet restore && dotnet build -->
Prevention
- Keep Uno.UI / Uno.WinUI package versions aligned across all projects.
- Run dotnet restore after changing package references.
- Check for package downgrade warnings that may cause type resolution failures.
When it happens
Trigger: The Roslyn compilation used by the source generator does not include a reference to the assembly that defines one of the mandatory types. For example, if Uno.UI or the WinUI reference assembly providing Border/SolidColorBrush is not referenced.
Common situations: A project references Uno.UI NuGet packages incorrectly or uses incompatible versions; the compilation is missing the WinUI/Uno type-forwarding assembly; package downgrade or restore failure left required assemblies unresolvable.
Related errors
- The type '{fullyQualifiedMetadataName}' is not found.
- Unable to resolve {symbol} (Reason: {errorTypeSymbol.Candida
- No valid setter found for attached property {name}
- Unable to find type {fullName}
- The type {0} could not be found
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/da64cb132485fc43.
Report an issue: GitHub.