dotnet/wpf · error · ArgumentNullException
resourceName
Error message
resourceName
What it means
The SplashScreen(Assembly,string) constructor throws ArgumentNullException when resourceName is null or an empty string (via string.IsNullOrEmpty). The resource name is required to locate the embedded splash image in the assembly's .g.resources.
Solutions
- Pass the correct embedded resource name (e.g. "SplashScreen.jpg" as added with Build Action: Resource)
- Validate the configured name before constructing and give a clear config error
- If the name is conditional, skip SplashScreen creation entirely when absent
Example fix
// before var splash = new SplashScreen(Assembly.GetExecutingAssembly(), config.SplashName); // null if unset // after if (string.IsNullOrEmpty(config.SplashName)) return; var splash = new SplashScreen(Assembly.GetExecutingAssembly(), config.SplashName);
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(resourceName)) throw new InvalidOperationException("Splash resource name is not configured");
var splash = new SplashScreen(resourceAssembly, resourceName); Type guard
bool HasSplashName(string name) => !string.IsNullOrEmpty(name);
Try / catch
try { var s = new SplashScreen(asm, name); } catch (ArgumentNullException) { /* skip splash: name not configured */ } Prevention
- Validate configuration before constructing SplashScreen
- Keep the resource name constant next to the embedded asset
- Fail fast at startup config load if the name is blank
When it happens
Trigger: new SplashScreen(assembly, null) or new SplashScreen(assembly, ""); passing a name from config/app resources that failed to load. Note the parameter message is 'resourceName'.
Common situations: Configuration where the splash resource name is read from appSettings and missing; refactoring removed the hardcoded resource name; build no longer embeds the resource but the name is also blank.
Related errors
- anchorLocator.Parts
- ArgumentNullException (buffer/sourceBuffer was IntPtr.Zero)
- ArgumentNullException: handle
- ArgumentNullException(nameof(assemblyName))
- ArgumentNullException(nameof(assemblyNames))
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/370a6f45a8cf2a7b.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs:51
private DispatcherTimer _timer;
private TimeSpan _fadeoutDuration;
private DateTime _fadeoutEnd;
private BLENDFUNCTION _blendFunction;
private readonly ResourceManager _resourceManager;
private Dispatcher _dispatcher;
private const string ClassName = "SplashScreen";
public SplashScreen(string resourceName) : this(Assembly.GetEntryAssembly(), resourceName)
{
}
public SplashScreen(Assembly resourceAssembly, string resourceName)
{
ArgumentNullException.ThrowIfNull(resourceAssembly);
if (string.IsNullOrEmpty(resourceName))
{
throw new ArgumentNullException(nameof(resourceName));
}
_resourceName = resourceName.ToLowerInvariant();
_hInstance = (HINSTANCE)Marshal.GetHINSTANCE(resourceAssembly.ManifestModule);
_resourceManager = new ResourceManager($"{ReflectionUtils.GetAssemblyPartialName(resourceAssembly)}.g", resourceAssembly);
}
public void Show(bool autoClose)
{
Show(autoClose, topMost: false);
}
public unsafe void Show(bool autoClose, bool topMost)
{
if (!_hwnd.IsNull)
{
return;
}View on GitHub (pinned to 81131a70a4)