Nov 29, 2012 at 4:41 PM
Edited Dec 10, 2012 at 11:04 PM
Great question! There is no release method. Simple Injector does not hold on to objects. Objects are not tracked and not disposed. This behavior is chosen because it is the easiest to work with and leads to the least surprises.
Exceptions to the rule are the RegisterPerWebRequest,
RegisterPerLifetimeScope and RegisterPerWcfOperation extension methods (available as integration packages). But even with these methods, there is no 'release'. Lifetime Scoped objects are released after you dispose the explicitly created
scope. Web Request and WCF operation objects are disposed when the web request and WCF operation ends. This is done for you under the covers. Again, no need to call a release method.
The registeration methods for these lifestyles allow overriding the default behavior and suppress disposing objects. And they offer a way to register services with another lifetime (such as transient) to be disposed when the scope or request ends.
In other words, these lifestyles implement the RRR pattern implicitly, without needing any explicit action from the user.