How to: Remove a Configuration Setting
The following procedure demonstrates how you can remove a configuration setting that you created through the Application Setting Manager.
To remove a configuration setting
- Add a reference to the SharePoint Guidance Library assembly. In Visual Studio, right-click your project node in Solution Explorer, and then click Add References. Click the Browse tab, and then navigate to the location of the Microsoft.Practices.SharePoint.Common.dll assembly.
- Using the same procedure, add a reference to the Microsoft.Practices.ServiceLocation.dll assembly.
- Add the following using statements to the top of your source code file.
- Use the SharePointServiceLocator.GetCurrent() method to get a reference to the current service locator instance.
- Use the service locator to request an implementation of the IConfigManager interface.
- (Optional) If your code is running in an environment where the SPContext.Current property is not available, call the SetWeb method and pass in an SPWeb object from which to build the storage hierarchy. If a SharePoint context exists, you can skip this step.
- Retrieve the IPropertyBag instance from which you want to remove your application setting.
- Call the IConfigManager.RemoveKeyFromPropertyBag method. The first parameter is the key string that you originally used to identify your configuration data. The second parameter is the IPropertyBag object in which the configuration setting is stored.