views:

118

answers:

1

When an object in Ninject is bound with InTransientScope(), the object isn't placed into the cache, since it's, er, transient and not scoped to anything.

When done with the object, I can call kernel.Release(obj); this passes through to the Cache where it retrieves the cached item and calls Pipeline.Deactivate using the cached entry.

But since transient objects aren't cached, this doesn't happen. I haven't been able to figure out where (or who) performs the deactivation for transient objects. Or is the assumption that transient objects are only ever activated, and that if I want a deactivateable object, I need to use some other scope?

+3  A: 

Your assumptions are correct. Transient objects are not tracked in Ninject and not controlled in the deactivation pipeline. It is your responsibility to clean up transient instances. If you want the kernel to manage your instances, then you need to use a built-in scope or a custom scope.

Ian Davis
Thanks. The 'interesting' thing is that they are activated just fine, so there's a mismatch in my head (something that's Activated should be Deactivated).
nwahmaet