Search code examples
c#genericsschedulerquartz.netjobs

Scheduling generic IJob<> with Quartz .NET and AdoJobStore


I'm developing simple scheduler using Quartz .NET. I want to Quartz persists all of jobs and triggers in database, so I set AdoJobStore and with "normal" jobs it works ok.

Now, I have problem with deserializing from database generic Jobs. I have class:

class DefaultJob<TEventType, TArgsType> : IJob{
 public void Execute(IJobExecutionContext context)
 {
         //do sth
 }
}

With RamJobStore and DefaultJob<,> everyting is ok - scheduling and running work.

With AdoJobStore and DefaultJob<,> I can schedule, Quartz saves it to database (I can see it via Management Studio), but when it tries to restore it from database, I'm getting:

A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
A first chance exception of type 'Quartz.JobPersistenceException' occurred in Quartz.dll
A first chance exception of type 'Quartz.JobPersistenceException' occurred in Quartz.dll

I debuged JobFactory, method NewJob isn't invoked at all. Something wrong happens before it.

Anybody could help?


Solution

  • OK. The question is pretty old. And seems it needs to be updated with new data. Now, Quartz.NET supports generic jobs. That's all. The sample in the question, now works perfectly.

    class DefaultJob<TEventType, TArgsType> : IJob {
        public Task Execute(IJobExecutionContext context)
        { }
    }