Monday, June 20, 2016

Disposing SharePoint Objects

Disposing SharePoint Objects


Yes. It's completely fine.

If you can use like below code in using block:
using(SPSite oSPsite = new SPSite("http://server"))
{
  using(SPWeb oSPWeb = oSPSite.OpenWeb())
   {
       str = oSPWeb.Title;
       str = oSPWeb.Url;
   }
}  


web.Dispose();
site.Dispose();

No comments:

Post a Comment