When I try to schedule a recurring job on startup, I get a JobLoadException:
RecurringJob.AddOrUpdate<ICOPAEDIHelper>("COPAEDI", copaEDIWorker => copaEDIWorker.DownloadAndProcessXMLFiles(JobCancellationToken.Null),
Cron.Daily(copaEDIScheduleTime.ToUniversalTime().Hour, copaEDIMinute));
But if I register a BackgroundJob with the same method, it works fine:
BackgroundJob.Enqueue<ICOPAEDIHelper>(copaEDIWorker => copaEDIWorker.DownloadAndProcessXMLFiles(JobCancellationToken.Null));
Here’s my interface with the method signature:
public interface ICOPAEDIHelper
{
void DownloadAndProcessXMLFiles(IJobCancellationToken cancellationToken);
}
If I modify my interface/signature and remove the IJobCancellationToken, everything works fine.
Here’s the stack trace:
And here’s the exception detail:
Hangfire.Common.JobLoadException
HResult=0x80131500
Message=Could not load the job. See inner exception for the details.
Source=Hangfire.Core
StackTrace:
at Hangfire.Storage.InvocationData.DeserializeJob()
at Hangfire.RecurringJobEntity…ctor(String recurringJobId, IDictionary2 recurringJob, ITimeZoneResolver timeZoneResolver, DateTime now) at Hangfire.RecurringJobExtensions.GetOrCreateRecurringJob(IStorageConnection connection, String recurringJobId, ITimeZoneResolver timeZoneResolver, DateTime now) at Hangfire.RecurringJobManager.AddOrUpdate(String recurringJobId, Job job, String cronExpression, RecurringJobOptions options) at Hangfire.RecurringJobManagerExtensions.AddOrUpdate(IRecurringJobManager manager, String recurringJobId, Job job, String cronExpression, TimeZoneInfo timeZone, String queue) at Hangfire.RecurringJob.AddOrUpdate[T](String recurringJobId, Expression
1 methodCall, String cronExpression, TimeZoneInfo timeZone, String queue)
at ERMA2.Startup.setupCOPAEDIScheduledTask(IContainer container) in C:\Projects\ERMA2Clone\ERMA2\Startup.cs:line 166
at ERMA2.Startup.<>c__DisplayClass9_0.b__0() in C:\Projects\ERMA2Clone\ERMA2\Startup.cs:line 65
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
Inner Exception 1:
InvalidOperationException: The type ERMA2BusinessLibrary.Models.ICOPAEDIHelper
does not contain a method with signature DownloadAndProcessXMLFiles()
I’ve been struggling with this all day. Thank you for any help you can provide.