{"record":{"id":"1fa8f842c078f70d","repo":"k1tbyte/Wand-Enhancer","slug":"embedded-resource-not-found-resourcename","errorCode":null,"errorMessage":"Embedded resource not found: {resourceName}","messagePattern":"Embedded resource not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"critical","filePath":"WandEnhancer/Core/Enhancer.cs","lineNumber":331,"sourceCode":"            {\n                return 0;\n            }\n\n            Directory.CreateDirectory(destinationDir);\n\n            foreach (var resourceName in resourceNames)\n            {\n                var relativePath = resourceName.Substring(resourcePrefix.Length)\n                    .Replace('/', Path.DirectorySeparatorChar)\n                    .Replace('\\\\', Path.DirectorySeparatorChar);\n                var destinationPath = Path.Combine(destinationDir, relativePath);\n                Directory.CreateDirectory(Path.GetDirectoryName(destinationPath) ?? destinationDir);\n\n                using (var resource = assembly.GetManifestResourceStream(resourceName))\n                {\n                    if (resource == null)\n                    {\n                        throw new FileNotFoundException($\"Embedded resource not found: {resourceName}\");\n                    }\n\n                    using (var output = File.Create(destinationPath))\n                    {\n                        resource.CopyTo(output);\n                    }\n                }\n            }\n\n            return resourceNames.Count;\n        }\n\n        private static string FindLocalCustomScriptsPath()\n        {\n            string executableDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);\n            if (string.IsNullOrEmpty(executableDirectory))\n            {\n                return null;","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/k1tbyte/Wand-Enhancer/blob/643c8f8b62cbb26fd3ac105b92497d9a9c445f08/WandEnhancer/Core/Enhancer.cs#L313-L349","documentation":"Inside CopyEmbeddedDirectory, a name returned by assembly.GetManifestResourceNames() (and already filtered by resourcePrefix) was iterated, but a follow-up GetManifestResourceStream(resourceName) returned null. Under normal .NET behavior a name from the same enumeration always yields a stream, so this signals a corrupt/inconsistent assembly load or a resource-name/prefix collision.","triggerScenarios":"CopyEmbeddedDirectory loop at Enhancer.cs:327-332: resource came from GetManifestResourceNames() but assembly.GetManifestResourceStream(resourceName) == null.","commonSituations":"Assembly loaded from a byte array or compressed/packed context where resource stream access differs from name enumeration; a tampered or partially-linked DLL; a rare multi-prefix collision where the prefix filter admits a name from a different resource root.","solutions":["Rebuild the assembly cleanly (resources may be mis-linked in the .csproj).","Inspect assembly.GetManifestResourceNames() output (ildasm / a scratch reflection probe) and confirm the resourcePrefix matches the real dotted names.","If loading via Assembly.Load(byte[]), ensure the load path preserves manifest resources.","Treat as a fatal build defect — do not suppress; the embedded remote panel is required."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Smoke-test resource access at startup\nvar names = Assembly.GetExecutingAssembly().GetManifestResourceNames();\nforeach (var n in names.Where(n => n.StartsWith(\"remote-panel/dist/\")))\n    if (Assembly.GetExecutingAssembly().GetManifestResourceStream(n) == null)\n        throw new InvalidOperationException(\"Corrupt resource: \" + n);","typeGuard":null,"tryCatchPattern":"try { enhancer.Patch(); }\ncatch (FileNotFoundException ex) when (ex.Message.Contains(\"Embedded resource not found\")) {\n    // rebuild assembly; this indicates a broken .csproj resource link\n}","preventionTips":["Add a unit test that opens every GetManifestResourceNames() stream.","Do not load the patcher assembly from compressed/packed sources.","Keep resource prefixes stable in the .csproj LogicalName settings."],"tags":["embedded-resources","build","reflection"],"backgroundTag":null,"analyzedSha":"643c8f8b62cbb26fd3ac105b92497d9a9c445f08","analyzedAt":"2026-08-13T14:17:43.823Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}