How to use Quartz.net in a console application [error is shown]?

I am using Quartz.Net to schedule a task. I tried like wise.

I launched the console application for visual studio and added two links ie Quartz.dll and Common.Logging.dll along with System.Web.Services;

Then I encoded a bit for the normal task, as indicated on the link http://simplequartzschedulerincsharp.blogspot.com/ (They claim that it works)

But as soon as I tried to run the program, it gave an error like "There is no link to Quartz.all", but I added this already.

Why is this happening?

Also somewhere, I noticed that you need to install Quartz.Server.Service in order to use it, etc. etc.

I ask you, please, to dictate to me a simple but working example and moments that I miss?

+4
source share
1 answer

The example on the site is probably out of date.

I made some changes to the classes used, and now it starts:

using System; using Quartz; using Quartz.Impl; using Quartz.Impl.Triggers; // Necessary references: // Quartz dll // Common.Logging // System.Web // System.Web.Services namespace QuartzExample { class Program { private static IScheduler _scheduler; static void Main(string[] args) { ISchedulerFactory schedulerFactory = new StdSchedulerFactory(); _scheduler = schedulerFactory.GetScheduler(); _scheduler.Start(); Console.WriteLine("Starting Scheduler"); AddJob(); } public static void AddJob() { IMyJob myJob = new MyJob(); //This Constructor needs to be parameterless JobDetailImpl jobDetail = new JobDetailImpl("Job1", "Group1", myJob.GetType()); CronTriggerImpl trigger = new CronTriggerImpl("Trigger1", "Group1", "0 * 8-17 * * ?"); //run every minute between the hours of 8am and 5pm _scheduler.ScheduleJob(jobDetail, trigger); DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc(); Console.WriteLine("Next Fire Time:" + nextFireTime.Value); } } internal class MyJob : IMyJob { public void Execute(IJobExecutionContext context) { Console.WriteLine("In MyJob class"); DoMoreWork(); } public void DoMoreWork() { Console.WriteLine("Do More Work"); } } internal interface IMyJob : IJob { } } 
+10
source

Source: https://habr.com/ru/post/1391278/


All Articles