Sharing a Lifetime Manager across types

Jan 19, 2011 at 2:53 PM

I have the requirement of registering several types with the container, and every type needs to use the same kind of LifetimeManager (the HierarchicalLifetimeManager).

Is it valid to create one instance of HierarchicalLifetimeManager and pass that instance to every invocation of RegisterType? Would doing that cause undesirable side effects compared to creating a separate HierarchicalLifetimeManager for each type?


Jan 19, 2011 at 6:29 PM

No, it is not valid to share lifetime manager instances across different registrations, and the container will detect and throw and error if you try to do this.

Before we put in the error detection, you got some seriously weird error messages and bizarre behaviors. So don't do it.