HangfireIO/Hangfire · error · ArgumentNullException

app

Error message

app

What it means

Thrown as ArgumentNullException by the obsolete MapHangfireDashboard OWIN extension when the 'app' IAppBuilder argument is null. The method is marked [Obsolete] and delegates to the modern UseHangfireDashboard pipeline; passing a null app builder means there is no pipeline to map the dashboard onto.

Source

Thrown at src/Hangfire.Core/Obsolete/DashboardOwinExtensions.cs:118

        /// <summary>
        /// Maps dashboard to the app builder pipeline at the specified path
        /// with given authorization filters that apply to any request and
        /// storage instance that is used to query the information.
        /// </summary>
        /// <param name="app">The app builder</param>
        /// <param name="dashboardPath">The path to map dashboard</param>
        /// <param name="appPath">The application path on Back To Site link</param>
        /// <param name="authorizationFilters">Array of authorization filters</param>
        /// <param name="storage">The storage instance</param>
        [Obsolete("Please use `IAppBuilder.UseHangfireDashboard` OWIN extension method instead. Will be removed in version 2.0.0.")]
        public static void MapHangfireDashboard(
            [NotNull] this IAppBuilder app,
            string dashboardPath,
            string appPath,
            IEnumerable<IAuthorizationFilter> authorizationFilters,
            JobStorage storage)
        {
            if (app == null) throw new ArgumentNullException(nameof(app));

            SignatureConversions.AddConversions(app);

            app.Map(dashboardPath, subApp => subApp.Use<DashboardMiddleware>(
                appPath,
                storage,
                DashboardRoutes.Routes,
                authorizationFilters));
        }
    }
}

View on GitHub (pinned to c236dd0f93)

Solutions

  1. Replace the obsolete MapHangfireDashboard call with the non-obsolete IAppBuilder.UseHangfireDashboard extension, which is the supported API.
  2. Ensure the IAppBuilder instance is the one received in your OWIN Startup.Configuration(IAppBuilder app) method and is non-null.
  3. Verify no conditional code path reassigns the app variable to null before the call.

Example fix

// before
DashboardOwinExtensions.MapHangfireDashboard(null, "/hangfire", "/", filters, storage);

// after
app.UseHangfireDashboard("/hangfire", new DashboardOptions { AuthorizationFilters = filters });
Defensive patterns

Strategy: validation

Validate before calling

if (app == null) throw new ArgumentNullException(nameof(app));
// or just use the supported API:
app.UseHangfireDashboard();

Type guard

// _ = app ?? throw new ArgumentNullException(nameof(app));

Prevention

When it happens

Trigger: Calling app.MapHangfireDashboard(...) where 'app' (the 'this IAppBuilder' receiver) is null — e.g. invoking the extension method on a null variable, or calling it as a static method with null as the first argument.

Common situations: A Startup.Configuration method that calls MapHangfireDashboard on a field or property that was never assigned; DI/migration code where the IAppBuilder reference is null because the OWIN host wasn't initialized; copy-paste from a sample that assumed a non-null app context.

Related errors


AI-assisted analysis of HangfireIO/Hangfire@c236dd0f93 (2026-08-13). Data as JSON: /api/errors/b2604937e35c4533. Report an issue: GitHub.