When is a Transient-scope object deactivated in Ninject?

When an object in Ninject is associated with InTransientScope() , the object is not cached because it is, er, transient and not attached to anything.

When you are done with the object, I can call kernel.Release(obj) ; it goes into the cache where it retrieves the cached item and calls Pipeline.Deactivate using the cached entry.

But since temporary objects are not cached, this does not happen. I could not figure out where (or who) is doing the deactivation for the transition objects. Or is it an assumption that the transition objects are only activated, and that if I want a deactivated object, I need to use a different scope?

+7
c # ioc-container ninject
source share
1 answer

Your assumptions are correct. Transitional objects are not monitored in Ninject and are not monitored in the deactivation pipeline. You are responsible for clearing temporary instances. If you want the kernel to manage your instances, you need to use the built-in scope or custom scope.

+8
source share

All Articles