1

I have this api endpoint which run C# hangfire.

RecurringJob.AddOrUpdate<IIngestService>(x => x.Process("ABC"), cronExpression, TimeZoneInfo.Local);
RecurringJob.AddOrUpdate<IIngestService>(x => x.Process("XYZ"), cronExpression, TimeZoneInfo.Local);

Problem is it always run Process("XYZ") only. Then I figure that I have to include recurringjobid if the method name are the same.

RecurringJob.AddOrUpdate<IIngestService>("ABC", x => x.Process("ABC"), cronExpression, TimeZoneInfo.Local);
RecurringJob.AddOrUpdate<IIngestService>("XYZ", x => x.Process("XYZ"), cronExpression, TimeZoneInfo.Local);

When I run the job manually from HangFire web, it works without error. But, when hangfire scheduler starts the job automatically after one minute (My cron job is * * * * *), it breaks.

The error message is:

System.InvalidOperationException: Recurring job can't be scheduled, see inner exception for details. ---> Hangfire.Common.JobLoadException: Could not load the job. See inner exception for the details. ---> System.TypeLoadException: Could not load type 'xxx.IIngestService' from assembly 'xxx.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)

Steve
  • 1,485
  • 3
  • 17
  • 45
  • 2
    Try to use [fuslogvw.exe](https://stackoverflow.com/a/1674318/2557855) to find out why you can't load the assembly – Artur Apr 17 '21 at 20:03
  • 1
    What is your .NET version, I tried to reproduce issue in .NET Core 3.1 and .NET 5 but it is working fine. This issue is open already with Hangfire: https://github.com/HangfireIO/Hangfire/issues?q=is%3Aopen+Recurring. – Nikhil Apr 21 '21 at 03:25
  • I'm using .Net core 3.1 – Steve Apr 21 '21 at 04:12
  • Might want to show what project/packages are involved (e.g. what does your `.csproj` look like, etc.) – Kit Apr 23 '21 at 02:59

0 Answers0