{"record":{"id":"4c6447e7e38de6ca","repo":"AvaloniaUI/Avalonia","slug":"could-not-find-manifest-resource-stream-name","errorCode":null,"errorMessage":"Could not find manifest resource stream '{_name}',","messagePattern":"Could not find manifest resource stream '(.+?)',","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Platform/Internal/AssetDescriptor.cs","lineNumber":27,"sourceCode":"    Stream GetStream();\n    Assembly Assembly { get; }\n}\n\ninternal class AssemblyResourceDescriptor : IAssetDescriptor\n{\n    private readonly Assembly _asm;\n    private readonly string _name;\n\n    public AssemblyResourceDescriptor(Assembly asm, string name)\n    {\n        _asm = asm;\n        _name = name;\n    }\n\n    public Stream GetStream()\n    {\n        var s = _asm.GetManifestResourceStream(_name);\n        return s ?? throw new InvalidOperationException($\"Could not find manifest resource stream '{_name}',\");\n    }\n\n    public Assembly Assembly => _asm;\n}\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","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Platform/Internal/AssetDescriptor.cs#L9-L45","documentation":"AssemblyResourceDescriptor.GetStream() resolves a named manifest resource from an Assembly via GetManifestResourceStream(_name) and throws InvalidOperationException when that call returns null, i.e. the assembly has no embedded resource matching the stored name. It is the low-level path the Avalonia asset loader uses to fetch an assembly-embedded (default C# build action 'Embedded Resource') asset stream. A null here means the resource name and the assembly's actual manifest resources do not line up.","triggerScenarios":"Calling IAssetDescriptor.GetStream() on an AssetDescriptor produced for a regular manifest resource after the loader resolved the URI to an (asm, name) pair, where _asm.GetManifestResourceStream(_name) yields null. Happens through StandardAssetLoader.Open/OpenAndGetAssembly when the resolved descriptor is an AssemblyResourceDescriptor whose name is not present in _asm.GetManifestResourceNames().","commonSituations":"The resource was added with the wrong build action (e.g. 'None'/'Content' instead of 'Embedded Resource'), the file was renamed/moved after the asset reference was compiled in, an IL linker/trimmer removed the embedded resource, or the wrong assembly was registered with the asset loader so the name lookup happens against an assembly that never owned it.","solutions":["Verify the resource exists at runtime: inspect assembly.GetManifestResourceNames() and confirm _name is present; fix the build action or path to match.","Ensure the file's MSBuild build action is 'Embedded Resource' (for manifest resources) or 'AvaloniaResource' (for avares), rebuild, and confirm it is emitted into the assembly.","If trimming/linking is on, add the resource (or its assembly) to the linker 'TrimmerRootDescriptor' / Preserve list so the embedded resource is not stripped.","Check that the assembly passed into AssemblyResourceDescriptor is the one that actually contains the resource, not a referenced facade assembly."],"exampleFix":"// before: wrong build action, resource missing from manifest\nvar s = _asm.GetManifestResourceStream(\"MyApp.Assets.icon.png\"); // null\n\n<!-- after: set build action to 'Embedded Resource' in the .csproj/properties, then -->\nvar names = _asm.GetManifestResourceNames();\nvar s = _asm.GetManifestResourceStream(names.First(n => n.EndsWith(\"icon.png\")));","handlingStrategy":"validation","validationCode":"string name = \"MyNamespace.Assets.icon.png\";\nbool present = _asm.GetManifestResourceNames().Contains(name);\nif (!present) return; // or log and degrade\nusing var s = _asm.GetManifestResourceStream(name)!;","typeGuard":"bool ResourceExists(Assembly asm, string name) => asm.GetManifestResourceNames().Contains(name);","tryCatchPattern":null,"preventionTips":["Set the correct MSBuild build action ('Embedded Resource' for manifest resources, 'AvaloniaResource' for avares).","Rebuild after renaming/moving resource files so the embedded name updates.","When trimming, root resource-bearing assemblies or add a TrimmerRootDescriptor.","Log GetManifestResourceNames() at startup in diagnostics builds to catch missing resources early."],"tags":["avalonia","assets","embedded-resource","manifest","resource-loading"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}