I recently added an IoC container to my Hangfire jobs and I noticed that now when my jobs get enqueued they will either succeed on the first run or fail multiple times before randomly succeeding. Every time it fails I get the same exception: System.MissingMethodException: Cannot create an instance of an interface.
It almost seems like the JobActivator doesn’t know how to inject my services but then suddenly can and will run the job successfully.
As far as my code goes I am doing the following in my ConfigureServices method:
Then in my Configure method:
Where my HangfireActivator is my IoC container using the default .NET core service provider.
When I enqueue the job I am doing the following:
jobId = _client.Enqueue(() => newJob.Invoke(null, job.Properties));
I am running my Hangfire client as a Windows service and there is only one instance of my Hangfire client. I am also using the latest version of Hangfire (1.6.20). My job storage is using Couchbase. Any advice would be appreciated.