You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When DefaultScopedLifestyle is set to ScopedLifestyle.Flowing collection elements that are registered as Scoped can be only resolved from the first scope. Trying to resolve them in any consequent scope throws an exception.
Unhandled exception. SimpleInjector.ActivationException: Cannot access a disposed object.
Object name: 'SimpleInjector.Scope'.
---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'SimpleInjector.Scope'.
at SimpleInjector.Scope.ThrowObjectDisposedException()
at SimpleInjector.Scope.GetInstanceInternal(ScopedRegistration registration)
at SimpleInjector.Scope.GetInstance[TImplementation](ScopedRegistration registration, Scope scope)
at SimpleInjector.Advanced.Internal.LazyScopedRegistration`1.GetInstance(Scope scope)
at lambda_method7(Closure )
at SimpleInjector.InstanceProducer.GetInstance()
--- End of inner exception stack trace ---
at SimpleInjector.InstanceProducer.GetInstance()
at SimpleInjector.Internals.ContainerControlledCollection`1.CopyTo(TService[] array, Int32 arrayIndex)
at SimpleInjector.Internals.FlowingContainerControlledCollection`1.CopyTo(TService[] array, Int32 arrayIndex)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at SimpleInjector.InstanceProducer.GetInstance()
at SimpleInjector.Container.GetInstance(Type serviceType)
at SimpleInjector.Scope.GetInstance(Type serviceType)
at SimpleInjector.Scope.GetInstance[TService]()
And there is a difference in resolving scoped collections and resolving scoped single instances with DefaultScopedLifestyle set to ScopedLifestyle.Flowing.
Two bugs for the price of one. Thanks for these very clear and reproducible bug reports.
I've got some bad news though, which is that I don't have a work around available and it might take some time for me to publish a new release that fixes these issues. ETA mid July.
When
DefaultScopedLifestyle
is set toScopedLifestyle.Flowing
collection elements that are registered as Scoped can be only resolved from the first scope. Trying to resolve them in any consequent scope throws an exception.And there is a difference in resolving scoped collections and resolving scoped single instances with
DefaultScopedLifestyle
set toScopedLifestyle.Flowing
.The text was updated successfully, but these errors were encountered: