Wednesday, November 2, 2011

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

I recently faced this error while i was working on some object model and by looking into the code i realized that i did a little mistake.

This error itself states everything. I used the current site object in the using clause while performing some operation. we should never close the SPContext.Current.Site when we deal with any coding. If we have manually declared any site or web object, then only we have to dispose them.

I made this correction and my code worked well.

I hope this helps others not to repeat the same mistake again.

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com