Not good coding practice found in a book by Arpan Shah. Sharepoint 2010 Development with Visual Studio 2010

Posted on

There is not a big deal in this error from the author, but its interesting that somebody from Microsoft itself makes this mistake after its revealed in the disposal best practices.

Chapter 3:  Introduction o the Sharepoint Object Model.

Page 185.

He used:

using(SPWeb rootWeb = site.RootWeb)

{

}

This is not a good coding practice because the RootWeb does not need disposal, I had SPRequest errors in my log in the past because of this exact same line.  SO AVOID IT.

this is documented here:

http://sharepoint.stackexchange.com/questions/33264/spdispose-false-positive

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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