Le réseau pour les développeurs > Forums - Accueil > SharePoint - Development and Programming > Dispose SPWeb object inside Feature Receiver? Or don't?
Poser une questionPoser une question
 

TraitéeDispose SPWeb object inside Feature Receiver? Or don't?

Réponses

  • lundi 8 septembre 2008 20:18Tony Testa MVPMVPMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée
    I just looked at some old event handlers i wrote and I always cleaned up the SPWeb object.

    BUT if your using properties.feature.parent, you would NOT want to kill the object because you would be killing the object that is running your code, same as in a webpart, you won't want to kill the SPContext.Current.Web object because its running your webpart.

    Typically in my event handlers I need to run code elevated, so i create the SPWeb or SPSite objects inside the elevated code and use the ID or URL from the properties collection to create the objects, that way I am creating new objects and can dispose of them knowing that I am not killing the object that is running my code.

Toutes les réponses