title: Quartz.net Create with job with Dependency Injection
body: <p>I am trying to execute a Quartz scheduler job in .NET with a non-empty constructor and I try to use the default Dependency Injection of .NET to supply the dependencies. This is my job class which needs a dependency injection</p>
  <pre><code>public class MyJob : IJob 
  {
    private readonly ILogger _logger;
  
    public MyJob(ILogger&lt;MyJob&gt; logger)
    {
      _logger = logger ?? throw new ArgumentNullException(nameof(logger));  
    }
  
    public Task Execute(IJobExecutionContext context)
    {
      _logger.LogDebug(&quot;It's working!&quot;);
    }
  }
  </code></pre>
  <p>And this is how I build the job</p>
  <pre><code>IJobDetail jobDetail = JobBuilder.Create&lt;MyJob&gt;().WithIdentity(&quot;MyID&quot;, &quot;MyGroup&quot;).Build();
  var triggerBuilder = TriggerBuilder.Create()
    .WithIdentity(&quot;MyID&quot;)
    .StartAt(DateTime.Now)
    .WithCronSchedule(&quot;*/1 * * * * ?&quot;); // Every second
  var trigger = triggerBuilder.Build();
  _scheduler.ScheduleJob(jobDetail, trigger)
  </code></pre>
  <p>Now, I have defined in my app configuration the following</p>
  <pre><code>// Quartz configuration.
  services.AddQuartz(q =&gt;
  {
      // Add dependency injection.
      q.UseMicrosoftDependencyInjectionScopedJobFactory(options =&gt;
      {
          // if we don't have the job in DI, allow fallback
          // to configure via default constructor
          options.AllowDefaultConstructor = true;
      });
  });
  services.AddTransient&lt;MyJob&gt;();
  // Also tried services.AddTransient&lt;IJob, MyJob&gt;();
  </code></pre>
  <p>As defined in the <a href="https://www.quartz-scheduler.net/documentation/quartz-3.x/packages/microsoft-di-integration.html#di-aware-job-factories" rel="nofollow noreferrer">documentation on DI</a>. Yet when I rebuild my solution and run the server, the following error is thrown</p>
  <blockquote>
  <p>Quartz.SchedulerException: Problem instantiating class 'MyProject.MyNamespace.Myjob: Cannot instantiate type which has no empty constructor
  Parameter name: MyJob' ---&gt; System.ArgumentException: Cannot instantiate type which has no empty constructor</p>
  </blockquote>
  <p>Yet, I explicitely defined to add MS DI in the setup for Quartz to use, following their documentation. So how could I nonetheless inject dependencies? I am using Quartz 3.2.4 and I installed the 'Quartz.Extensions.DependencyInjection' package (also 3.2.4).</p>