Repository navigation
Do DI Factories need their own scope? #4672
Replies: 2 comments 5 replies
|
I tried to look in the source code and bumped into this issue when trying to find |
|
Because your code calls AddControllers, I presume you are using IMvcBuilder. Then:
Unless In contrast, |
Uh oh!
There was an error while loading. Please reload this page.
When creating a di factory that resolves instances from the service provider, do I need to create a new scope before resolving the instance or is the service provider provided already in a scope so that I don't risk resolving instances from the root?
For example, I want to register
JsonSerializerOptionsto 1) avoid making the mistake of creating more instances than necessary and 2) avoid having to register the converters that I already have registered inAddJsonOptions. Should I then resolveIOptions<JsonOptions>directly from the service provider or should I create a new scope first?All reactions