“Cannot save the property settings for this Web Part” error when using SmartPart in SharePoint

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: 0×80020009 (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.

If you enjoyed this post, please share it!

    2 comments on ““Cannot save the property settings for this Web Part” error when using SmartPart in SharePoint

    1. Sreenath H B says:

      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.

      Have fun!

      Sreenath

    2. Chris Barnes says:

      Thanks Sreenath!

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>