dotnet/maui · error · BuildException

XC0124

XC0124

Error message

Resource "{0}" not found.

What it means

XC0124 ResourceMissing thrown by RDSourceTypeConverter when an assembly specified via the ';assembly=' suffix in a ResourceDictionary Source value is not found among the current module's assembly references. The converter looks up the assembly reference by name; if none matches, the build fails before even trying to locate the resource file.

Source

Thrown at src/Controls/src/Build.Tasks/CompiledConverters/RDSourceTypeConverter.cs:39

			while (!(rootNode is ILRootNode))
				rootNode = rootNode.Parent;

			var rdNode = node.Parent as ElementNode;

			var rootTargetPath = XamlCTask.GetPathForType(context.Cache, currentModule, ((ILRootNode)rootNode).TypeReference);

			var module = currentModule;
			string asmName = null;
			if (value.Contains(";assembly="))
			{
				var parts = value.Split([";assembly="], StringSplitOptions.RemoveEmptyEntries);
				value = parts[0];
				asmName = parts[1];
				if (currentModule.Assembly.Name.Name != asmName)
				{
					var ar = currentModule.AssemblyReferences.FirstOrDefault(ar => ar.Name == asmName);
					if (ar == null)
						throw new BuildException(BuildExceptionCode.ResourceMissing, node, null, value);
					module = currentModule.AssemblyResolver.Resolve(ar).MainModule;
				}
			}
			var uri = new Uri(value, UriKind.Relative);

			var resourcePath = ResourceDictionary.RDSourceTypeConverter.GetResourcePath(uri, rootTargetPath);

			foreach (var instruction in CreateUri(context, (ILRootNode)rootNode, value, node, asmName))
				yield return instruction;

			var uriVarDef = new VariableDefinition(currentModule.ImportReference(context.Cache, ("System", "System", "Uri")));
			body.Variables.Add(uriVarDef);
			yield return Create(Stloc, uriVarDef);

			var resourceTypeRef = GetTypeForPath(context.Cache, module, resourcePath);
			if (resourceTypeRef is not null)
			{
				foreach (var instruction in CreateResourceDictionaryType(context, currentModule, module, node, rdNode, resourceTypeRef, uriVarDef))

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Ensure the specified assembly name exactly matches an assembly reference in the current project's .csproj (ProjectReference or Reference).
  2. Verify the assembly name by checking the .csproj <AssemblyName> or the DLL name — use the assembly name, not the file path.
  3. Add a missing project or assembly reference, or correct typos in the ';assembly=' value.
  4. If referencing a resource within the same assembly, omit the ';assembly=' suffix entirely.

Example fix

<!-- before -->
<ResourceDictionary Source="Resources/Styles.xaml;assembly=MyApp.Shard" />

<!-- after -->
<ResourceDictionary Source="Resources/Styles.xaml;assembly=MyApp.Shared" />
Defensive patterns

Strategy: validation

Validate before calling

// Validate that an assembly referenced in a ResourceDictionary Source exists in the project
static bool IsAssemblyReferenced(string assemblyName, IEnumerable<AssemblyName> referencedAssemblies)
    => referencedAssemblies.Any(a => a.Name == assemblyName);

Prevention

When it happens

Trigger: Using Source="Resources/Styles.xaml;assembly=MyApp.Shared" on a ResourceDictionary where 'MyApp.Shared' is not referenced by the current project. A typo in the assembly name, or the referenced project has not been built/added as a project reference.

Common situations: Renaming a project/assembly without updating Source references. Referencing an assembly by its output DLL name rather than its assembly name. Forgetting to add a project reference to the assembly containing the resource. Case-sensitivity mismatches in the assembly name.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/0c58c01075e512b8. Report an issue: GitHub.