Closed Ditriksss closed 8 months ago
@Ditriksss Thanks for the test, will check a bit later.
@Ditriksss Yeah, something strange - probably a bug.
When you omit the var singleton = container.Resolve<ServiceSingleton>();
, everything working as it should.
But when the ServiceResolver
is injected into the singleton first, for some reason it is cached as bound to the root container,
messing up the resolution in the transient.
I will look for the fix.
@Ditriksss Sorry for the late answer, but the problem is the cache in this case, and I believe it's hard to solve in the current version.
But for now you may use the workaround registering the ServiceResolver
as:
container.Register<ServiceResolver>(setup: Setup.With(useParentReuse: true));
Basically, it means that ServiceResolver
reuse will be dependent on the parent service and so it won't be cached.
I'll keep the issue opened to see if there is any better solution in v6.0.
Hello!
Assumption: We have service singleton and service transient. Both of them have service A which has IResolver.
We've found that if service singleton is resolved before scope, scope context is lost for IResolver inside scope. We assumed that if service A is registered as a transient then there is no issue to inject it to singleton then to scope.
We are getting following error: DryIoc.ContainerException: 'code: Error.NoCurrentScope; message: No current scope is available - probably you are registering to or resolving from outside of the scope. It also may be because of the scoped dependency has singletons in its parent chain so the dependency is resolved from the root container resolver. Current resolver context is: container without scope.'
Could you eleborate why this error occur ?
Code to repeat this error: