{"record":{"id":"ed3784c18c033804","repo":"AvaloniaUI/Avalonia","slug":"could-not-find-manifest-resource-stream-constant","errorCode":null,"errorMessage":"Could not find manifest resource stream '{Constants.AvaloniaResourceName}',","messagePattern":"Could not find manifest resource stream '(.+?)',","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Platform/Internal/AssetDescriptor.cs","lineNumber":49,"sourceCode":"}\n        \ninternal class AvaloniaResourceDescriptor : IAssetDescriptor\n{\n    private readonly int _offset;\n    private readonly int _length;\n    public Assembly Assembly { get; }\n\n    public AvaloniaResourceDescriptor(Assembly asm, int offset, int length)\n    {\n        _offset = offset;\n        _length = length;\n        Assembly = asm;\n    }\n\n    public Stream GetStream()\n    {\n        var s = Assembly.GetManifestResourceStream(Constants.AvaloniaResourceName) ??\n                throw new InvalidOperationException($\"Could not find manifest resource stream '{Constants.AvaloniaResourceName}',\");\n        return new SlicedStream(s, _offset, _length);\n    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":53,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Platform/Internal/AssetDescriptor.cs#L31-L53","documentation":"AvaloniaResourceDescriptor.GetStream() reads from the single combined 'avalonia.resources' blob that Avalonia's build task generates, addressed by an (offset, length) slice. It throws InvalidOperationException when Assembly.GetManifestResourceStream(Constants.AvaloniaResourceName) returns null, i.e. the combined blob was never embedded into the assembly. Unlike [340], the resource name is a fixed constant, so failure always means the avalonia.resources blob itself is absent.","triggerScenarios":"Resolving any 'avares://' asset whose owning assembly was indexed by the Avalonia build task but the final assembly does not contain the 'avalonia.resources' manifest entry, so the descriptor's SlicedStream cannot be opened. Triggered through the standard asset loader Open/GetStream path for an AvaloniaResource-backed asset.","commonSituations":"The project references Avalonia but lacks the Avalonia.Resource build items / AvaloniaGenerateReswowInput or the build task didn't run (older SDK, custom .csproj that overrides targets), the resource file's build action is wrong, source generators/targets were disabled, or the assembly is being loaded from a location that wasn't rebuilt after switching to the avares resource model.","solutions":["Confirm the assembly contains the blob at runtime: assembly.GetManifestResourceNames().Contains(\"avalonia.resources\") must be true; if false, rebuild with the Avalonia targets active.","Verify the asset's MSBuild build action is 'AvaloniaResource' and the project imports the Avalonia targets / uses the Avalonia SDK so the combined blob is generated.","Make sure the owning assembly of the avares:// URI is the one registered with the asset loader and is the freshly built output.","If publishing trimmed, root the 'avalonia.resources' manifest entry or disable trimming for asset-bearing assemblies."],"exampleFix":"// before: asset referenced via avares:// but blob missing\nvar s = asm.GetManifestResourceStream(\"avalonia.resources\"); // null -> throw\n\n// after: ensure build action and targets\n<!-- .csproj -->\n<ItemGroup>\n  <AvaloniaResource Include=\"Assets\\**\\*\" />\n</ItemGroup>\n<!-- and confirm: -->\nbool ok = asm.GetManifestResourceNames().Contains(\"avalonia.resources\");","handlingStrategy":"validation","validationCode":"bool hasBlob = asm.GetManifestResourceNames().Contains(\"avalonia.resources\");\nif (!hasBlob) { /* rebuild / fix build action */ return; }","typeGuard":"bool HasAvaloniaResourcesBlob(Assembly asm) => asm.GetManifestResourceNames().Contains(\"avalonia.resources\");","tryCatchPattern":null,"preventionTips":["Ensure the project uses the Avalonia SDK / imports Avalonia targets so the 'avalonia.resources' blob is generated.","Set asset build action to 'AvaloniaResource', not 'Embedded Resource'.","After publish, smoke-test asset loading to catch trimming-induced blob removal.","Register only freshly-built assemblies with the asset loader."],"tags":["avalonia","assets","avares","avalonia-resource","resource-loading"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}