Building Quartz.Net on the fly
The job class must implement the Job interface. "I created a simple job with Quartz.Net 1.0.3
public class SimpleTestJob : IJob
{
public virtual void Execute(JobExecutionContext context)
{
System.Diagnostics.EventLog.WriteEntry("QuartzTest", "This is a test run");
}
}
Then I will try to dynamically add the job above to the Quartz server
I first got the type with reflection
string jobType = "Scheduler.Quartz.Jobs.SimpleTestJob,Scheduler.Quartz,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null";
var schedType= Type.GetType(jobType, false, true);
It works. Then I try to create a JobDetail object
JobDetail job = job = new JobDetail(jobName, groupName, schedType.GetType());
But I am getting an error from the Quartz.Net framework.
"Job class must implement the Job interface."
Please, help
+3
source to share
2 answers
I am using Quartz 1.0.3 compiled with .net 3.5.
But schedType.GetType
a return type with a version 4 RunTime attribute.
Indeed, I don't need to use the GetType function because I have the type I got before
var schedType= Type.GetType(jobType, false, true);
So my fix was
JobDetail job = new JobDetail(jobName, groupName, schedType);
+2
source to share