Search code examples
asp.net-core-2.0aspnetboilerplate

UseHangfireServer throws exception


I have a problem with my ASP.NET Boilerplate Core 2.0 application.

I worked a lot on my application layer and now I want to try the code in the MVC project. But when I try to start the application I get the following error:

System.InvalidOperationException: 'Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddHangfire' inside the call to 'ConfigureServices(...)' in the application startup code.'

This error occures in line (102): app.UseHangfireServer();

I don't know what is wrong with hangfire. I didn't change code in the startup.cs file.


Solution

  • This is what the error message is telling you to do:

    services.AddHangfire(config =>
    {
        config.UseSqlServerStorage(_appConfiguration.GetConnectionString("Default"));
    });
    

    Add the above on the line before:

    services.AddScoped<IWebResourceManager, WebResourceManager>();