SharePoint Blog - René Hézser

Anmelden  RSS Feed RSS Feed
Startet die Suche

Archive

Kategorien

Links

Andere Blogs




ITaCS GmbH


Error 0x80020009  

Feb 072008

I am sure you all know the Best Practices: Using Disposable Windows SharePoint Services Objects Guide from Microsoft. If not, read it :-)

Please be carefull what objects you dispose after you don't need them anymore. If you dispose the SPContext.Current.Site object, you might get strange behaviours. e.g. you might not be able to save Webpart properties. Doing so, will generate an error:

Cannot save the property settings for this Web Part. Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))

   1: SPSite site = SPContext.Current.Site;
   2: // do something with it
   3: site.Dispose();

This code fragment will actually dispose the SPContext.Current.Site object!

   1: SPSite site = new SPSite(SPContext.Current.Site.ID);
   2: // do something
   3: site.Dispose();
The above sample will work!
 
Posted by René Hézser | 1  Comment | Trackback Url  | 0  Links to this post | Bookmark this post with:        
Tags: Development, SharePoint
Technorati Tags: ,

Links to this post

Comments

commented on  Wednesday, February 10, 2010  9:07 AM  by  omlin
Great post, thank you!

Name *:
URL:
Email:
Kommentar:


CAPTCHA Image Validation