I recently deployed a custom user control using SmartPart on SharePoint 2007, and although everything else seemed to work fine, I came across the following error when trying to edit the properties (in my case, the chrome type and width):
Cannot save the property settings for this Web Part. Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))
I managed to resolve this, thanks to an MSDN forum post, by changing one of my lines of code:
using (SPSite oSiteCollection = SPContext.Current.Site)
to the slightly more long-winded:
using (SPSite oSiteCollection = new SPSite(SPContext.Current.Site.ID))
I’m not sure why using SPContext.Current.Site directly (versus creating a new SPSite object) causes this behaviour, but at least it’s a simple fix.
2 comments on ““Cannot save the property settings for this Web Part” error when using SmartPart in SharePoint”
The using tag in C# has a special purpose of disposing of objects declared inside it. So by using the “using” tag to refer a SPContext.Current.Site will cause an SPSite object to get disposed, which you did not create.
That probably is causing the error and you have found one of the ways to fix it.