{"record":{"id":"9019b1968bcec582","repo":"dotnet/wpf","slug":"sr-unabletolocateresource","errorCode":null,"errorMessage":"SR.UnableToLocateResource","messagePattern":"SR\\.UnableToLocateResource","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs","lineNumber":75,"sourceCode":"        }\n\n        public void Show(bool autoClose)\n        {\n            Show(autoClose, topMost: false);\n        }\n\n        public unsafe void Show(bool autoClose, bool topMost)\n        {\n            if (!_hwnd.IsNull)\n            {\n                return;\n            }\n\n            // If we've already been shown it isn't an error to call show\n            // again (maybe you forgot) since you will still be shown state.\n\n            using UnmanagedMemoryStream resourceStream = GetResourceStream()\n                ?? throw new IOException(SR.Format(SR.UnableToLocateResource, _resourceName));\n\n            resourceStream.Seek(0, SeekOrigin.Begin); // ensure stream position\n\n            CreateLayeredWindowFromImgBuffer(new(resourceStream.PositionPointer, (int)resourceStream.Length), topMost);\n\n            if (autoClose)\n            {\n                Dispatcher.CurrentDispatcher.BeginInvoke(\n                    DispatcherPriority.Loaded,\n                    (DispatcherOperationCallback)(static arg =>\n                    {\n                        ((SplashScreen)arg).Close(TimeSpan.FromSeconds(0.3));\n                        return null;\n                    }),\n                    this);\n            }\n\n            // The HWND that we just created is owned by this thread.  When we close we should ensure that it ","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs#L57-L93","documentation":"SplashScreen.Show throws IOException when GetResourceStream() returns null, wrapping SR.UnableToLocateResource with the resource name. The splash resource could not be found in the assembly's generated .g resources, so the splash window cannot be created.","triggerScenarios":"Calling Show (or Show(false, true)) when the named resource is not embedded in the assembly — resource file missing, wrong Build Action (not 'Resource'), file excluded from the project, or name case/extension mismatch.","commonSituations":"Switching build configurations that skip the resource; renaming the splash image without updating the constructor argument; resource in a satellite/other assembly than the one passed to the constructor; MSBuild Resource inclusion removed during migration.","solutions":["Ensure the image exists in the project with Build Action = Resource so it is compiled into assemblyname.g","Verify the resourceName passed to the constructor matches the embedded name (extension included, path-relative)","Confirm you are passing the assembly that actually contains the resource","Catch IOException around Show and degrade gracefully (skip splash)","Check the .g.resources content (e.g. via ILSpy/AssemblyReader) to confirm the exact resource key"],"exampleFix":"// before\nsplash.Show(false); // IOException: UnableToLocateResource\n// after\ntry { splash.Show(false); }\ncatch (IOException ex) { Trace.WriteLine($\"Splash skipped: {ex.Message}\"); }","handlingStrategy":"try-catch","validationCode":"bool resourceExists = Assembly.GetExecutingAssembly()\n    .GetManifestResourceNames()\n    .Any(n => n.EndsWith(\".g.resources\") );\n// or verify via ResourceManager GetStream before Show","typeGuard":"bool SplashResourceAvailable(SplashScreen s, ResourceManager rm, string name) => rm.GetStream(name) != null;","tryCatchPattern":"try { splash.Show(false); } catch (IOException ex) { Trace.WriteLine($\"Splash resource missing: {ex.Message}\"); /* continue startup */ }","preventionTips":["Set Build Action = Resource on the splash image so it lands in assemblyname.g","Keep resourceName in sync with the embedded file name/extension","Pass the assembly that actually embeds the resource","Test Show in release builds where resource embedding settings may differ"],"tags":["wpf","splashscreen","missing-resource","io-exception"],"backgroundTag":"resource-not-found","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}