Skip to content

An error occurred while initialization of scheduler services An instance of Quartz 3 Scheduler expected #95

Description

@ytcitsupport-jlin

I'm trying to use CrystalQuartz with my ASP.NET Core application.
Environment:

  • Framework: .NET 5.0
  • Quartz.AspNetCore: 3.4.0
  • CrystalQuartz.AspNetCore: 6.8.1

This is my setup in the Startup.cs

public void ConfigureServices(IServiceCollection services){
...
services.AddSingleton<IJobFactory, SingletonJobFactory>();
            services.AddSingleton<ISchedulerFactory, StdSchedulerFactory>();
            var schedulerFactory = new StdSchedulerFactory();
            var scheduler = schedulerFactory.GetScheduler().Result;
            services.AddSingleton<IScheduler>(scheduler);

            // Add our job
            services.AddSingleton<HelloJob>();
            services.AddSingleton(new JobSchedule(
                jobType: typeof(HelloJob),
                cronExpression: "0/5 * * * * ?")); // run every 5 seconds

            services.AddHostedService<QuartzHostedService>();
...
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env){
...
app.UseCrystalQuartz(() => Scheduler);
...
}

But the scheduler runs OK but when I open CrystalQuartz on the browser, I saw the error message

An error occurred while initialization of scheduler services
An instance of Quartz 3 Scheduler expected

Did I set it up wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions