类型或名称空间名称“集合”在名称空间“ Quartz”中不存在

时间:2020-02-05 14:13:22

标签: c# quartz-scheduler

尝试使用以下代码安排多个作业

            // construct a scheduler factory
            ISchedulerFactory schedFact = new StdSchedulerFactory();


            // get a scheduler
            Scheduler = schedFact.GetScheduler().GetAwaiter().GetResult();


            // define the job and tie it to our ReportSyncJob class
            IJobDetail jobDetail = JobBuilder.Create<ReportSyncJob>()
                .WithIdentity("ReportSyncJob", "groupProcessQueue")
                .Build();


            // Trigger the job to run now, and then every day on weekdays
            ITrigger trigger1 = TriggerBuilder.Create()
              .WithIdentity("ReportSyncJobTrigger", "groupProcessQueue")
              .StartNow()
              .WithCronSchedule("0 0 3 1 / 1 * ? *")
              .Build();


            // Trigger the job to run now, and then every day on weekdays
            ITrigger trigger2 = TriggerBuilder.Create()
              .WithIdentity("ReportSyncJobTrigger", "groupProcessQueue")
              .StartNow()
              .WithCronSchedule("0 0 6 1/1 * ? *")
              .Build();

       26-> var dictionary = new Dictionary<IJobDetail, Quartz.Collection.ISet<ITrigger>>();
            var dic = new Dictionary<Quartz.IJobDetail, Quartz.Collection.ISet<ITrigger>>();
            dictionary.Add(jobDetail, new Quartz.Collection.HashSet<ITrigger>()
                      {
                          trigger1,
                          trigger2
                      });
            Scheduler.ScheduleJobs(dictionary, true);
            Scheduler.Start();

但是在第26行中的代码箭头中出现了以下异常

名称空间“ Quartz”中不存在类型或名称空间名称“ Collection”(您是否缺少程序集引用?)

非常感谢您的回答。预先感谢。

2 个答案:

答案 0 :(得分:0)

此界面Quartz.Collection.ISet位于here。 Quartz(在Quartz.dll中)版本: 2.2.1.400

namespace Quartz.Collection

API documentation link for version 2.0

您可能在项目中使用了最新的NuGet软件包或更新的版本,这就是IDE找不到它的原因。 Quartz.NET已经在version 3.0上。当然,API发生了很大变化。

答案 1 :(得分:-2)

如此博客文章(https://www.koskila.net/how-to-fix-the-type-or-namespace-name-services-does-not-exist-in-the-namespace-microsoft-aspnetcore-components-are-you-missing-an-assembly-reference/所示,降级Microsoft.VisualStudio.Web.CodeGeneration.Design可能会有所帮助,或者将所有包升级为预览版9(如果将Visual Studio更新为Visual Studio 2019 16.3预览版3(或大概是16.2.4),