{"record":{"id":"1dff1ffcad8ac7ee","repo":"HangfireIO/Hangfire","slug":"assembly","errorCode":null,"errorMessage":"assembly","messagePattern":"assembly","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/GlobalConfigurationExtensions.cs","lineNumber":393,"sourceCode":"        }\n\n        public static IGlobalConfiguration UseDefaultCulture(\n            [NotNull] this IGlobalConfiguration configuration,\n            [CanBeNull] CultureInfo culture,\n            [CanBeNull] CultureInfo uiCulture,\n            bool captureDefault)\n        {\n            if (configuration == null) throw new ArgumentNullException(nameof(configuration));\n            return configuration.UseFilter(new CaptureCultureAttribute(culture?.Name, uiCulture?.Name, captureDefault));\n        }\n\n        public static IGlobalConfiguration UseDashboardStylesheet(\n            [NotNull] this IGlobalConfiguration configuration,\n            [NotNull] Assembly assembly,\n            [NotNull] string resource)\n        {\n            if (configuration == null) throw new ArgumentNullException(nameof(configuration));\n            if (assembly == null) throw new ArgumentNullException(nameof(assembly));\n            if (resource == null) throw new ArgumentNullException(nameof(resource));\n\n            DashboardRoutes.AddStylesheet(assembly, resource);\n            return configuration;\n        }\n\n        public static IGlobalConfiguration UseDashboardStylesheetDarkMode(\n            [NotNull] this IGlobalConfiguration configuration,\n            [NotNull] Assembly assembly,\n            [NotNull] string resource)\n        {\n            if (configuration == null) throw new ArgumentNullException(nameof(configuration));\n            if (assembly == null) throw new ArgumentNullException(nameof(assembly));\n            if (resource == null) throw new ArgumentNullException(nameof(resource));\n\n            DashboardRoutes.AddStylesheetDarkMode(assembly, resource);\n            return configuration;\n        }","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/GlobalConfigurationExtensions.cs#L375-L411","documentation":"UseDashboardStylesheet registers an embedded CSS resource for the Hangfire dashboard via DashboardRoutes.AddStylesheet(assembly, resource). The `assembly` argument identifies the assembly containing the embedded resource stream. Hangfire guards it with ArgumentNullException(nameof(assembly)) because AddStylesheet needs a concrete Assembly to call GetManifestResourceStream on. A null assembly means the resource lookup has no source to read from.","triggerScenarios":"Calling `.UseDashboardStylesheet(config, assembly, \"My.Style.css\")` where `assembly` is null — e.g. `Assembly.GetEntryAssembly()` returned null (common in some in-proc/test hosts and certain ASP.NET Classic hosting scenarios), or the developer passed `null` instead of `typeof(Startup).Assembly` / `Assembly.GetExecutingAssembly()`.","commonSituations":"Using `Assembly.GetEntryAssembly()` which returns null in some test runners, IIS-hosted apps without an entry assembly, or worker scenarios; a dynamically-loaded assembly that failed to load and was left null; copy-pasting the stylesheet registration call but forgetting to fill in the assembly argument; third-party dashboard themes that resolve their assembly from a nullable field.","solutions":["Pass a concrete assembly: `typeof(Startup).Assembly` or `Assembly.GetExecutingAssembly()` instead of a possibly-null value.","Avoid `Assembly.GetEntryAssembly()` for resource lookups, or guard it: `var asm = Assembly.GetEntryAssembly() ?? typeof(Startup).Assembly;`","Validate the assembly is non-null before calling: `ArgumentNullException.ThrowIfNull(assembly);`","Confirm the resource string matches an actual `[assembly: EmbeddedResource]`/manifest resource name in that assembly."],"exampleFix":"// before\nGlobalConfiguration.Configuration.UseDashboardStylesheet(\n    Assembly.GetEntryAssembly(), // null in some hosts => ANE(assembly)\n    \"MyApp.styles.min.css\");\n\n// after\nGlobalConfiguration.Configuration.UseDashboardStylesheet(\n    typeof(Startup).Assembly,\n    \"MyApp.styles.min.css\");","handlingStrategy":"validation","validationCode":"ArgumentNullException.ThrowIfNull(assembly);\n// Avoid Assembly.GetEntryAssembly() when it may be null:\nvar asm = assembly ?? typeof(Startup).Assembly;\nGlobalConfiguration.Configuration.UseDashboardStylesheet(asm, resource);","typeGuard":"static Assembly ResolveAssembly()\n    => Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();\n\nstatic bool IsAssemblyAvailable(Assembly? a) => a is not null;","tryCatchPattern":"try { configuration.UseDashboardStylesheet(assembly, resource); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"assembly\")\n{ throw new InvalidOperationException(\n    \"Dashboard stylesheet assembly is null; use typeof(Startup).Assembly instead of Assembly.GetEntryAssembly().\", ex); }","preventionTips":["Pass a concrete assembly (typeof(Startup).Assembly or Assembly.GetExecutingAssembly()) instead of a nullable value.","Avoid Assembly.GetEntryAssembly() for resource lookups; it returns null in some hosts and test runners.","Validate the assembly is non-null and that the resource name matches an actual manifest resource.","Use a fallback: var asm = Assembly.GetEntryAssembly() ?? typeof(Startup).Assembly;"],"tags":["hangfire","dashboard","stylesheet","embedded-resource","argumentnullexception"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}