We are leaving Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Unable to resolve service for type 'Hangfire.IBatchJobClient' while attempting to activate '...'

Hi there,

I’m a satisfied user of Hangfire, and I’ve recently started using Hangfire Pro. Its batch functionality is great and works well when I invoke it via the static BatchJob.StartNew() methods.

I’m now trying to start a batch job using constructor based dependency injection (I dislike using statics) but when I try it like this, the DI container is unable to instantiate my job as it has no registration for IBatchJobClient.

Is there a registration step I’m missing (I’ve not found a services.AddHangfirePro() method), or do I have to do a registration step myself?

Hi Alex,

Yes, unfortunately there’s no integration package for batches and .NET Core yet, and IBatchJobClient should be registered with:

    x => new BatchJobClient(x.GetRequiredService<JobStorage>()));
1 Like