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

16 Dec
December 16, 2010

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!
    Tags: , , , ,
    2 replies
    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!


    2. Chris Barnes says:

      Thanks Sreenath!

    Leave a Reply

    Want to join the discussion?
    Feel free to contribute!

    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>

    © 2014 Chris Barnes