Wednesday, November 7, 2012

Trying to use an SPWeb object that has been closed or disposed and is no longer valid.

Hi Guys,

You may have faced this kind of error while coding the webparts and provisioning them in SharePoint pages. May be you will face this issue while trying to edit a page, that having the webpart with below code

using(SPWeb web = SPContext.Current.Web)
{
//Your code here
}

Issue is with using statement, its disposing your SPWeb object automatically when you leaving using block. Use below than the above block

SPWeb web = SPContext.Current.Web

Hope you will figure it out within your code.

Happy coding guys,

Buddike

No comments:

Post a Comment