类型或名称空间名称'Collection'在名称空间'Quartz'中不存在

问题描述 投票:0回答:2

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

            // 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行中出现以下异常,并在代码中用箭头标记

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

您的好答将受到高度赞赏。预先感谢。

c# quartz-scheduler
2个回答
0
投票

看起来像该接口位于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发生了很大变化。


-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),

© www.soinside.com 2019 - 2024. All rights reserved.