Open Pycnomerus opened 5 months ago
The workaround is to set the lifetime to Scoped
instead of the default Singleton
builder.Services.AddMediator(configure => configure.Lifetime = ServiceLifetime.Scoped, typeof(Program).Assembly);
It would be nice to re-evaluate the default Lifetime
value. It has been set to Singleton
for performance reasons. I'm not sure how many projects would be impacted by this change.
Describe the bug when using the library default, if you register anything that will be used by a command as scoped. the application crash. with an impossible to resolve configuration error.
this will probably also break typed httpclient.
To Reproduce Steps to reproduce the behavior: when using mediator default registration register a scoped service. try to use it inside any IRequest object.
Expected behavior all type of scopes registration should work without changing the default behaviour. this is especially a concern since it's not an expected behavior, and introduce risk namely to use Typed HttpClient
Screenshots
Additional context here's a test sample project to reproduce