MediatR: Error when using MediatR with NetCore's new Worker service

I am currently using MediatR successfully with my .net core web project. But unfortunately when using a Worker service the DI breaks and can not find my Handlers. Worker Services require an Environment Var of "DOTNET_ENVIRONMENT" : "Development" and my web project uses "ASPNETCORE_ENVIRONMENT" : "Development" when i switch my worker service to use the later of the two EV vars, there are no problems with my worker services finding the Handlers, but the worker services picks up the wrong appsettings.[ENV].json (Production instead of Development).

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 17 (10 by maintainers)

Commits related to this issue

Most upvoted comments

It’s weird that changing the environment variables cause it to work / not work - does this have any impact? I assume your worker service is what is injecting IMediator, which is scoped by default