Do Not Dispose SPFeatureReceiverProperties.Feature.Parent

I can’t find a dedicated post about it, so I thought I’d draw attention to this thread in the MSDN forums where Michael Washam [MSFT] replied…

Do not dispose properties.Feature.Parent..

However, if you use .ParentWeb or anything else the same rules apply..

Now, the rule for SPWeb.ParentWeb is that it should not be disposed if you don’t own the child SPWeb, which we don’t, but you get the idea. It would be great if SPDisposeCheck would catch this—Roger?

I only point it out specifically because feature receiver examples are often posted online and I see Parent disposed all the time.

Advertisements