unoplatform/uno · error · InvalidOperationException

Unable to resolve {symbol} (Reason: {errorTypeSymbol.Candida

Error message

Unable to resolve {symbol} (Reason: {errorTypeSymbol.CandidateReason}, Location:{location}, Candidates: {candidates})

What it means

ThrowOnErrorSymbol inspects a resolved symbol and, if it is an IErrorTypeSymbol, throws InvalidOperationException with the CandidateReason, source location, and candidate symbols. Roslyn produces an IErrorTypeSymbol when a name resolves ambiguously to multiple candidates or cannot be bound, so this surfaces ambiguous/unresolvable XAML type references.

Source

Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/RoslynMetadataHelper.cs:47

			_findTypeByFullName = Funcs.Create<string, ITypeSymbol?>(SourceFindTypeByFullName).AsLockedMemoized();
			_findContentProperty = Funcs.Create<INamedTypeSymbol, IPropertySymbol?>(SourceFindContentProperty).AsLockedMemoized();
			_isAttachedProperty = Funcs.Create<INamedTypeSymbol?, string, bool>(SourceIsAttachedProperty).AsLockedMemoized();
			_getAttachedPropertyType = Funcs.Create<INamedTypeSymbol, string, INamedTypeSymbol>(SourceGetAttachedPropertyType).AsLockedMemoized();
			_isTypeImplemented = Funcs.Create<INamedTypeSymbol, bool>(SourceIsTypeImplemented).AsLockedMemoized();
			_findPropertyByOwnerSymbol = Funcs.Create<INamedTypeSymbol?, string, ISymbol?>(SourceFindPropertyByOwnerSymbol).AsLockedMemoized();
			_findLocalizableDeclaredProperties = Funcs.Create<INamedTypeSymbol, string[]>(SourceFindLocalizableDeclaredProperties).AsLockedMemoized();
			_findEventType = Funcs.Create<INamedTypeSymbol?, string, IEventSymbol?>(SourceFindEventType).AsLockedMemoized();
		}

		private static void ThrowOnErrorSymbol(ISymbol symbol)
		{
			if (symbol is IErrorTypeSymbol errorTypeSymbol)
			{
				var candidates = string.Join(";", errorTypeSymbol.CandidateSymbols);
				var location = symbol.Locations.FirstOrDefault()?.ToString() ?? "Unknown";

				throw new InvalidOperationException(
					$"Unable to resolve {symbol} (Reason: {errorTypeSymbol.CandidateReason}, Location:{location}, Candidates: {candidates})"
				);
			}
		}

		public ITypeSymbol? FindTypeByFullName(string fullName)
		{
			return _findTypeByFullName(fullName);
		}

		private ITypeSymbol? SourceFindTypeByFullName(string fullName)
		{
			var symbol = Compilation.GetTypeByMetadataName(fullName);

			if (symbol?.Kind == SymbolKind.ErrorType)
			{
				symbol = null;
			}

View on GitHub (pinned to 0418340488)

Solutions

  1. Read the reported candidates and qualify the XAML type with the fully-qualified xmlns of the intended one.
  2. Remove or alias the conflicting PackageReference/ProjectReference.
  3. Use an explicit xmlns prefix mapped to the correct namespace/assembly.

Example fix

<!-- before: 'Button' ambiguous across two namespaces -->
<Button />
<!-- after -->
<myui:Button xmlns:myui="using:Microsoft.UI.Xaml.Controls" />
Defensive patterns

Strategy: validation

Validate before calling

// Lint XAML for type names that resolve to >1 candidate before building
// (tooling: run the XAML compiler in a dry parse pass and fail on ambiguity)

Prevention

When it happens

Trigger: A XAML type reference resolves to multiple candidate symbols (ambiguous) or none, e.g. two referenced assemblies each define a type with the same name and both namespaces are in scope.

Common situations: Adding a PackageReference that introduces a duplicate type name; an xmlns pulling in multiple namespaces with a clashing type; a rename that leaves the old type shadowed.

Related errors


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