microsoft/aspire · error · InvalidOperationException
Embedded resource ' ' not found.
Error message
Embedded resource '{name}' not found. What it means
The Rust code generator loads its template/runtime support files from embedded resources in the Aspire.Hosting.CodeGeneration.Rust assembly, using the namespace `Aspire.Hosting.CodeGeneration.Rust.Resources.{name}`. `GetEmbeddedResource` throws this InvalidOperationException when the requested resource name does not match any manifest resource in the assembly. Like the other embedded-resource errors, it signals a packaging/build problem rather than user input error.
Solutions
- Rebuild from a clean state or reinstall the official Aspire.Hosting.CodeGeneration.Rust package so embedded resources are intact.
- Confirm the requested resource file exists under the Rust Resources directory and is listed as `<EmbeddedResource>` in the project file.
- Inspect the assembly's manifest resource names to find the actual name and fix a mismatch if building from source.
- File an issue with the missing resource name if this occurs on an official package build.
Defensive patterns
Strategy: try-catch
Validate before calling
var hasRustResources = typeof(AtsRustCodeGenerator).Assembly
.GetManifestResourceNames()
.Any(n => n.StartsWith("Aspire.Hosting.CodeGeneration.Rust.Resources.")); Try / catch
try {
string template = GetEmbeddedResource(name);
} catch (InvalidOperationException ex) when (ex.Message.Contains("Embedded resource")) {
// reinstall/rebuild before retrying generation
} Prevention
- Keep Rust template files and EmbeddedResource csproj entries synchronized.
- Clean-rebuild after renaming resource folders.
- Prefer official package builds over custom stripped ones.
When it happens
Trigger: Calling GenerateDistributedApplication in the Rust generator when a template resource it requests was not embedded (file missing/renamed, csproj EmbeddedResource entry removed, or assembly built without resources).
Common situations: Custom builds that exclude .rs template files; a renamed resource folder breaking the expected namespace; unofficial or corrupted package installs.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Embedded resource ' ' not found.
- Embedded resource ' ' not found.
- Embedded resource 'microvenv.py' not found.
- -32602
- argument ' ' passed to capability ' ' contains a circular…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/ec58618ec60611dc.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs:73
pub mod aspire;
pub use transport::*;
pub use base::*;
pub use aspire::*;
""",
["transport.rs"] = GetEmbeddedResource("transport.rs"),
["base.rs"] = GetEmbeddedResource("base.rs"),
["aspire.rs"] = GenerateAspireSdk(context)
};
}
private static string GetEmbeddedResource(string name)
{
var assembly = Assembly.GetExecutingAssembly();
var resourceName = $"Aspire.Hosting.CodeGeneration.Rust.Resources.{name}";
using var stream = assembly.GetManifestResourceStream(resourceName)
?? throw new InvalidOperationException($"Embedded resource '{name}' not found.");
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
}
private string GenerateAspireSdk(AtsContext context)
{
using var stringWriter = new StringWriter(CultureInfo.InvariantCulture);
_writer = stringWriter;
var capabilities = context.Capabilities;
var dtoTypes = context.DtoTypes;
var enumTypes = context.EnumTypes;
_enumNames.Clear();
foreach (var enumType in enumTypes)
{
_enumNames[enumType.TypeId] = SanitizeIdentifier(enumType.Name);
}View on GitHub (pinned to 25830f84bd)