1

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.

Harry Stuart
  • 1,781
  • 2
  • 24
  • 39
  • Possible duplicate of [Is there an in memory job storage package for Hangfire?](https://stackoverflow.com/questions/43206740/is-there-an-in-memory-job-storage-package-for-hangfire) – Moien Tajik Dec 26 '18 at 14:01
  • No, because I am encountering issues even with those proposed solutions. – Harry Stuart Dec 26 '18 at 16:16
  • `RecurringJob.AddOrUpdate` looks like a static method. you aren't initializing the asp.net core pipeline – Daniel A. White Dec 26 '18 at 19:05
  • Try to move `RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Minutely);` to `app.UseHangfireServer(); ` later. – Edward Dec 27 '18 at 02:41

1 Answers1

3

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

Ali Zeinali
  • 551
  • 4
  • 16