问题
I'm using Quartz.NET scheduler as a stand-alone windows service while from an ASP.NET app I sechedule jobs. I've a separate job assembly and i'm getting the following error
Could not load file or assembly 'AV.Scheduler.Jobs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Here is my code,
JobDetail jobDetail = new JobDetail("testJob", null, typeof(TestJob));
//created trigger which will fire every minute starting immediately
SimpleTrigger trigger = new SimpleTrigger("testTrigger",
null,
DateTime.UtcNow,
null,
1,
TimeSpan.FromMinutes(1));
scheduler.ScheduleJob(jobDetail, trigger);
I'm getting the error at the last line.
回答1:
Although already answered (in comments), I am adding an answer here for future reference.
In order for the Quartz service to execute your custom job, it needs to be somehow able to locate the job assembly. One solution is, as you suggested, to add it as a reference to the console application that starts and stops the Quartz service. However, a console application isn't always present. If this is the case, you need to place the job assembly in the same folder that Quartz.dll is located (the version of the dll that is used by the service).
An excellent resource for Quartz.Net is http://jvilalta.blogspot.com/. From particular interest regarding this topic are the following blog posts:
- Getting Started With Quartz.Net: Part 1
- Creating a Custom Job in Quartz.Net
来源:https://stackoverflow.com/questions/6519285/could-not-load-job-assembly-error-in-quartz-net