none
Dispose SPWeb object inside Feature Receiver? Or don't?

คำตอบ

  • 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.
    • ทำเครื่องหมายเป็นคำตอบโดย Michael Washam - MSFT 8 กันยายน 2551 20:25
    8 กันยายน 2551 20:18

ตอบทั้งหมด