命名空间 'Quartz' 中不存在类型或命名空间名称 'Collection'
The type or namespace name 'Collection' does not exist in the namespace 'Quartz'
尝试使用以下代码安排多个作业
// 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 行中出现以下异常,代码中用箭头标记
The type or namespace name 'Collection' does not exist in the namespace 'Quartz' (are you missing an assembly reference?)
非常感谢您的回答。提前致谢。
正如博客 post 所建议的 ( 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),
此接口 Quartz.Collection.ISet
位于 here。石英(在Quartz.dll)版本:2.2.1.400
namespace Quartz.Collection
API documentation link for version 2.0
您可能在项目中使用了最新的 NuGet 包或更新版本,这就是 IDE 找不到它的原因。 Quartz.NET 已经在 version 3.0 上了。当然 API 改变了很多。
尝试使用以下代码安排多个作业
// 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 行中出现以下异常,代码中用箭头标记
The type or namespace name 'Collection' does not exist in the namespace 'Quartz' (are you missing an assembly reference?)
非常感谢您的回答。提前致谢。
正如博客 post 所建议的 ( 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),
此接口 Quartz.Collection.ISet
位于 here。石英(在Quartz.dll)版本:2.2.1.400
namespace Quartz.Collection
API documentation link for version 2.0
您可能在项目中使用了最新的 NuGet 包或更新版本,这就是 IDE 找不到它的原因。 Quartz.NET 已经在 version 3.0 上了。当然 API 改变了很多。