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

2 Responses to “Do Not Dispose SPFeatureReceiverProperties.Feature.Parent”

  1. Aaron Powell Says:

    Haha yeah I’ve made the mistake of disposing of objects in a FeatureReceiver before, biiiig mistake

  2. Links (2/8/2009) « Steve Pietrek - Everything SharePoint Says:

    […] Do Not Dispose SPFeatureReceiverProperties.Feature.Parent […]


Comments are closed.

%d bloggers like this: