2

I have a problem with updating properties of sharepoint 2010 feature

this is my code :

using (SPSite site = new SPSite("http://vm-pc:2000"))
        {
            foreach (SPFeatureDefinition def in SPFarm.Local.FeatureDefinitions)
            {

                if (def.Scope == SPFeatureScope.WebApplication)
                {
                    if (def.GetTitle(System.Threading.Thread.CurrentThread.CurrentCulture) == "Configure Site Settings")
                    {
                        ((SPFeatureProperty)def.Properties[0]).Value = "5";
                        def.Properties.Update();
                        def.Update();

                    }
                }
            }
        }

The problem with def.Properties.Update();

It throws an exception :

Updating the properties of a feature definition is not supported.

Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
Mahmoud Samir
  • 1,008
  • 1
  • 7
  • 13

1 Answers1

0

Why dont you use the Property bag?

SPSite site = new SPSite("URL"); 
SPWeb web = site.RootWeb; 
web.Properties.Add("Key", "Value"); 
web.Properties.Update();

and get value:

web.AllProperties["Key"]
toma19
  • 101
  • 2
  • 5