Closed cheng93 closed 10 months ago
I believe IServiceScopeFactory
being injected into the service is not the root scope, but rather the request scope, thus it's being disposed.
I think it's due to this.
The resolver compiles down is equivalent to the following
scope => {
var inline_serviceScopeFactory = (IServiceScopeFactory) scope // this should probably be scope.Root
return new TestService(inline_serviceScopeFactory, ....)
}
https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scope-scenarios
Mentions that
IServiceScopeFactory
is a singleton. It also does not implementIDisposable
, which means I assume throughout the lifetime of the application it should be available.However I am finding that it is being disposed, probably due to
Container
also implementingIDisposable
, and is causing an issue.https://github.com/cheng93/ServiceScopeFactoryDisposed is a sample
calling http://localhost:5153/test will trigger it