IJob, ILogger, dependency injection confusion. #1914
Replies: 3 comments 2 replies
-
You probably need to set
|
Beta Was this translation helpful? Give feedback.
-
Thanks for your help, but my situation might be slightly unique because I might not be in Program.cs with builder/services/app available to me and MicrosoftDependencyInjectionJobFactory has a constructor expecting ServiceProvider and options. Thanks again. |
Beta Was this translation helpful? Give feedback.
-
I think my problem is that although I am doing below in Program.cs, when I do "BuildScheduler()" later, it doesn't know that I want DependencyInjectionJobFactory. I stumbled on your 4.0 code and SetLoggerFactory, that might be the solution given how I am doing things. Thanks again for trying.. :)
|
Beta Was this translation helpful? Give feedback.
-
I am using Quartz 3.5 with .Net 6
The Scheduler is defined just before app.RunAsync in Program.cs or later. We don't use "AddQuartz" because the database containing the Quartz tables may be defined after app start. Sample of SchedulerBuilder.Create below.
Error:
2023-02-13 10:48:01,050 [3] ERROR Quartz.Core.ErrorLogger - An error occurred instantiating job to be executed. job= 'MySite.MyJob'
Quartz.SchedulerException: Problem instantiating class 'MySite.Jobs.MyJob: Cannot instantiate type which has no empty constructor (Parameter 'MyJob')'
According to other messages and the sample code, this isn't supposed to be necessary: UseMicrosoftDependencyInjectionScopedJobFactory.
MyJob
Is there something I am missing in the SchedulerBuilder.Create syntax below?
Code to generate the scheduler
Thanks for any help you can provide.
Peter
Beta Was this translation helpful? Give feedback.
All reactions