Harry Stuart
Harry Stuart

Reputation: 1945

Hangfire ASP.NET Core packages

I have installed the packages:

Hangfire.AspNetCore Hangfire.MemoryStorage.Core

Here is my code:

using Hangfire;
using Hangfire.MemoryStorage;

public void ConfigureServices(IServiceCollection services)
{
    services.AddHangfire(c => c.UseStorage(GlobalConfiguration.Configuration.UseMemoryStorage()));
    services.AddMvc();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseHangfireServer(); 
}

...

public static void Main(string[] args)
{
    RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Minutely);
}

However, I am getting the error:

JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.

My application is running on ASP.NET Core.

Upvotes: 1

Views: 646

Answers (1)

Ali Zeinali
Ali Zeinali

Reputation: 571

The Main method run before Configure and ConfigureServices so you are trying to use Hangfire before it's configuration happen.

Upvotes: 4

Related Questions