简体   繁体   中英

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 .

Main方法在ConfigureConfigureServices之前运行,因此您在配置发生之前尝试使用Hangfire

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM