You cannot use RegisterInstance if you want to configure PerResolve. Either use RegisterInstance , which will always return the same instance of the object (i.e., the registration point of the instance) or use RegisterType and define PerResolveLifetimeManager .
RegisterInstance uses ContainerControlledLifetimeManager by default. The only other significant lifecycle manager for RegisterInstance is ExternallyControlledLifetimeManager .
TransientLifetimeManager and PerResolveLifetimeManager do not make sense, because these lifetimes should create a new instance every time you call Resolve .
PerThreadLifetimeManager useless in scripts where you do not control streaming.
Ladislav Mrnka
source share