unoplatform/uno · error · InvalidOperationException
Unsupported resource type for {reference.Display} ({referenc
Error message
Unsupported resource type for {reference.Display} ({reference.GetType()}) What it means
Thrown during InitializeResourceLoaders when iterating compilation references for localization resources. For each reference, GetAssemblyOrModuleSymbol is called; if the result is not an IAssemblySymbol (e.g. it is null or a module symbol), the exception includes the reference display name and its runtime type.
Source
Thrown at src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs:761
private static bool IsInsideUnoSolution(GeneratorExecutionContext context)
=> context.GetMSBuildPropertyValue("_IsUnoUISolution") == "true";
private void GenerateResourceLoader(IIndentedStringBuilder writer)
{
TryAnnotateWithGeneratorSource(writer);
writer.AppendLineIndented($"global::Windows.ApplicationModel.Resources.ResourceLoader.DefaultLanguage = \"{_defaultLanguage}\";");
writer.AppendLineIndented($"global::Windows.ApplicationModel.Resources.ResourceLoader.AddLookupAssembly(GetType().Assembly);");
foreach (var reference in _metadataHelper.Compilation.References)
{
if (_metadataHelper.Compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly)
{
BuildResourceLoaderFromAssembly(writer, assembly);
}
else
{
throw new InvalidOperationException($"Unsupported resource type for {reference.Display} ({reference.GetType()})");
}
}
}
private void BuildResourceLoaderFromAssembly(IIndentedStringBuilder writer, IAssemblySymbol assembly)
{
var unoHasLocalizationResourcesAttribute = assembly.GetAttributes().FirstOrDefault(a =>
SymbolEqualityComparer.Default.Equals(a.AttributeClass, Generation.AssemblyMetadataSymbol.Value)
&& a.ConstructorArguments.Length == 2
&& a.ConstructorArguments[0].Value is "UnoHasLocalizationResources");
var unoHasLocalizationResourcesAttributeDefined = unoHasLocalizationResourcesAttribute is not null;
var hasUnoHasLocalizationResourcesAttributeEnabled = unoHasLocalizationResourcesAttribute
?.ConstructorArguments[1]
.Value
?.ToString()
.Equals("True", StringComparison.OrdinalIgnoreCase) ?? false;
View on GitHub (pinned to 0418340488)
Solutions
- Check the reference display name in the error to identify the problematic assembly reference.
- Ensure all project references are standard assembly or project references.
- Try cleaning and restoring NuGet packages (dotnet clean && dotnet restore).
- If the reference is from an analyzer or source generator output, verify it is not being included as a compilation reference.
Defensive patterns
Strategy: fallback
Validate before calling
// If building the compilation programmatically, filter references to valid assemblies:
// foreach (var reference in compilation.References)
// {
// var sym = compilation.GetAssemblyOrModuleSymbol(reference);
// if (sym is IAssemblySymbol asm) { /* safe */ }
// else { /* log and skip — non-assembly reference encountered */ }
// } Prevention
- Keep NuGet packages clean and fully restored.
- Avoid adding non-standard references (streams, ref-emitted assemblies) to the compilation.
- Run dotnet clean && dotnet restore if the error appears after a package change.
When it happens
Trigger: A compilation reference that is not a standard assembly reference is encountered during the resource-loader initialization scan — e.g. a stream-based reference, a corrupted reference, or a reference type that the generator does not expect.
Common situations: Unusual or non-standard assembly references in the compilation (e.g. from analyzers, source generators, or ref-emitted assemblies); SDK or tooling version that produces a reference type not handled by the generator; a corrupted NuGet package reference.
Related errors
- type
- GetTSType: The type {type} is not supported (SpecialType: {t
- GetTSFieldType: The type {type} is not supported (SpecialTyp
- MSBuild property MSBuildProjectFullPath value {_projectFullP
- MSBuild property MSBuildProjectFullPath value {_projectFullP
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/df2906038539b549.
Report an issue: GitHub.