“Please close SPWeb objects when you are done with all objects obtained from them, but not before”

DO NOT use SPList directly from methods in webparts & application pages. SPList is a sharepoint object & will instantiate a new SPWeb Object,
if used outside of its parent SPweb object. Always perform operation on SPObjects with in the SPWeb(parent SPObject) context.

or else
We will get the exception with this message : “Please close SPWeb objects when you are done with all objects obtained from them, but not before

Muchos Muchos Gracias to Jonas for the explanation & pattern in this article 

Advertisements
Posted in Sharepoint 2010

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: