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

  1. Check the reference display name in the error to identify the problematic assembly reference.
  2. Ensure all project references are standard assembly or project references.
  3. Try cleaning and restoring NuGet packages (dotnet clean && dotnet restore).
  4. 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

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


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