Can You Come Up With A WHY Comment For This Code?
Posted by Davy Brion on February 18th, 2010
I just had to write the following code:
public class MyReleasePolicy : Castle.MicroKernel.Releasers.LifecycledComponentsReleasePolicy
{
public override void Track(object instance, Castle.MicroKernel.Burden burden)
{
if (!instance.GetType().FullName.StartsWith("NServiceBus"))
{
base.Track(instance, burden);
}
}
}
and then this:
IoC.Container.Kernel.ReleasePolicy = new MyReleasePolicy();
to make a problem go away.
Can you come up with a WHY comment? (the category of this post is another hint)

February 19th, 2010 at 6:56 am
Yeah I can, but I think this would be cheating;-)
February 19th, 2010 at 7:16 am
did you run into the same issue or are you talking about this hack when you say ‘cheating’? (which i’d certainly agree with :p)
February 19th, 2010 at 11:02 am
That’s interesting.
I don’t know NServiceBus, but I would guess it somehow either takes care of managing its own dependencies, or for some reason is incompatible with Windsor’s life-cycle management.
Do you plan a follow up post detailing the issue you’re working around here?
February 19th, 2010 at 11:04 am
@Krzysztof
“Do you plan a follow up post detailing the issue you’re working around here?”
by now you should know me well enough to know the answer to that question
February 19th, 2010 at 3:13 pm
I mean I know NSB’s ObjectBuilder from the inside and I am aware of this leak in it’s abstraction system — its dependency resolver abstraction has no notion of releasing components. Btw, it is Krzysztof who first turned my attention to this issue, in context of MetaContainer:)