title: .NET Core console app Mediatr command handler doesn't get called
body: <p>I'm facing a problem that Mediatr command handler is not called.
  I have the following solution structure.</p>
  
  <p><code>Project.sln
  -&gt; Application layer (.NET standard class library)
  -&gt; Jobs (.NET standard class library)
  -&gt; Job Server (.NET Core console app)</code></p>
  
  <p>The idea is that Job Server uses scheduler (Quartz.NET) to execute Jobs. The actual business logic is in Application layer. Application layer uses CQRS pattern which is wired using Mediatr. I'm using Microsoft dependency injection libraries.</p>
  
  <p>Job Server <code>Main</code> method (with DI code):</p>
  
  <pre><code>public class Program
  {
      static ManualResetEvent _quitEvent = new ManualResetEvent(false);
  
      static void Main(string[] args)
      {
          Console.WriteLine("Job Server started");
  
          //DI setup
          var serviceProvider = new ServiceCollection()
              .AddQuartz()
              .AddTransient&lt;InitializeJobServer&gt;()
              .AddTransient&lt;ProcessAdRssFeedsJob&gt;()
              .AddScoped&lt;IConfigService, ConfigService&gt;()
              .AddScoped&lt;IRssService, RssService&gt;()
              .AddScoped&lt;IBaseService, BaseService&gt;()
              .AddMediatR(typeof(ProcessAdSectionsRssCommand).GetType().Assembly)
              .AddDbContext&lt;MyDbContext&gt;(options =&gt;
                  options.UseNpgsql("xxx"))
              .AddMemoryCache()
              .BuildServiceProvider();
  
          Console.CancelKeyPress += (sender, eArgs) =&gt; {
              _quitEvent.Set();
              eArgs.Cancel = true;
          };
  
          Task.Run(async () =&gt;
          {
              await serviceProvider.GetService&lt;InitializeJobServer&gt;().Start();
          });
  
          _quitEvent.WaitOne();
          Console.WriteLine("Job Server ended");
      }
  }
  </code></pre>
  
  <p>Code from Quartz.net job:</p>
  
  <pre><code>[DisallowConcurrentExecution]
  public class ProcessAdRssFeedsJob : IJob
  {
      private readonly IMediator _mediator;
  
      public ProcessAdRssFeedsJob(IMediator mediator)
      {
          _mediator = mediator;
      }
  
      public Task Execute(IJobExecutionContext context)
      {
          try
          {
              _mediator.Send(new ProcessAdSectionsRssCommand());               
          }
          catch (Exception ex)
          {
              Console.WriteLine(ex);
          }
          return null;
      }
  }
  </code></pre>
  
  <p>Mediatr command:</p>
  
  <pre><code>public class ProcessAdSectionsRssCommand : IRequest&lt;bool&gt;
  {
  
      public class Handler : IRequestHandler&lt;ProcessAdSectionsRssCommand, bool&gt;
      {
          private readonly MyDbContext _context;
          private readonly IRssService _rssService;
          private readonly IConfigService _configService;
  
          public Handler(
              MyDbContext context,
              IRssService rssService,
              IConfigService configService)
          {
              _context = context;
              _rssService = rssService;
              _configService = configService;
          }
  
          public async Task&lt;bool&gt; Handle(ProcessAdSectionsRssCommand request, CancellationToken cancellationToken)
          {
              var config = await _configService.GetAllConfigs();
  
              var r0 = await _rssService.GetAdSectionRssUrls();
              // etc.
              return true;
          }
      }
  }
  </code></pre>
  
  <p>After debugging I've concluded that code stops executing after initializing <code>ProcessAdSectionsRssCommand</code> class (if I create an empty constructor, it will be executed). Unfortunately, I haven't got any actual error messages, I think some sort of exception might be swallowed. <code>Handler</code> class as far as I can tell never gets initialized.</p>
  
  <ul>
  <li>Mediatr version: 6.0.0 </li>
  <li>.NET code SDK version: 2.2 </li>
  <li>Microsoft DI version (Microsoft.Extensions.DependencyInjection): 2.2.0</li>
  </ul>
  
  <p>I suspect it's some sort of DI + Mediatr related issue. Anyone has any ideas?
  Thanks.</p>