I have a windows service which (at least used to) creates jobs from the xml config file. However I can't get it working.
This is my xml (jobs.config)
<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data
xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<schedule>
<job>
<name>FirstJob</name>
<group>DummyGroup</group>
<description>This is FirstJob</description>
<job-type>Test.TestJob, Test</job-type>
</job>
<trigger>
<simple>
<name>nativeJobExampleSimpleTrigger</name>
<group>nativeJobExampleSimpleTriggerGroup</group>
<description>Simple trigger to simply fire sample job</description>
<job-name>FirstJob</job-name>
<job-group>DummyGroup</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<repeat-count>5</repeat-count>
<repeat-interval>5000</repeat-interval>
</simple>
</trigger>
</schedule>
and this is the code to create my job.
var jobs = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "jobs.config");
var properties = new NameValueCollection
{
["quartz.scheduler.instanceName"] = "XmlConfiguredInstance",
["quartz.threadPool.threadCount"] = "5",
["quartz.threadPool.threadPriority"] = "Normal",
["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz",
["quartz.plugin.xml.fileNames"] = jobs
};
var sf = new StdSchedulerFactory(properties);
sched = sf.GetScheduler();
sched.Start();
var jgn = sched.GetJobGroupNames();
var count = jgn.Count;
No matter what I try, the value of count
is always zero and my job doesn't start. The path
to the config file is correct (I tried renaming the file to 1jobs.config and got "File not found exception."
I have tried several examples of config and code from documentation, the result is the same. Moving properties to myservice.exe.config doesn't change anything either. Jobs.config has read access for everyone.
However, if I try the same code and the same config in a WinForms app, it works like it's supposed to.