The Application Setting Manager

All enterprise-scale applications use configuration settings to some extent. Application configuration data provides the information that an application requires to be able to run in a specific deployment environment. For example, configuration data might include a connection string for a database, the location of a dependent SharePoint library or list, or information about the security context of the environment.

Managing application settings in a SharePoint environment introduces challenges beyond those encountered by developers who are familiar with ASP.NET and other platforms. First, the SharePoint environment employs a unique hierarchy that enables configuration at each logical level of its architecture—farm, Web application, site collection, site, and list. Second, developers need to account for the dynamic nature of SharePoint. Users can drop your Web Parts into many different pages and instantiate your templates in many different locations. This can have a major bearing on how you manage configuration options for your solutions.

There are also several different storage mechanisms for configuration settings, including the hierarchical object store, configuration files, property bags, and SharePoint lists. Each mechanism has advantages, disadvantages, and sometimes risks—for example, SharePoint property bags provide an easy-to-use storage mechanism, but developers risk corrupting the configuration database or the content database if they attempt to persist non-serializable types.

Note

For more information about the advantages and disadvantages of each storage mechanism, see Managing Application Configuration on MSDN. Although this content was developed for a previous version of SharePoint, the guidance is still valid for SharePoint 2010.

To help you to address these challenges, the SharePoint Guidance Library includes a reusable component named the Application Setting Manager. You can use the Application Setting Manager in your SharePoint applications to provide an easy, consistent, and type-safe means of storing and retrieving configuration data at any level of the SharePoint hierarchy.

This section includes the following topics that will help you to understand and use the Application Setting Manager:

  • What Does the Application Setting Manager Do? This topic provides a brief overview of the Application Setting Manager, the concepts behind it, and the features that it incorporates. It also provides a simple example of how you can programmatically interact with the Application Setting Manager.
  • When Should I Use the Application Setting Manager? This topic can help you to decide whether the Application Setting Manager is suitable for your requirements. It identifies key scenarios in which the setting manager may be useful to you, and it explains the benefits and limitations of using the setting manager.
  • Developing Applications Using the Application Setting Manager. This section describes how to approach the key development tasks that you will encounter when using the Application Setting Manager, such as adding, removing, and retrieving application settings.
  • Key Scenarios. This section shows you how to use the Application Setting Manager in the most common end-to-end scenarios.
  • Design of the Application Setting Manager. This topic explains in more detail how the setting manager works, including the background and rationale behind the component.
  • Developer How-to Topics. This section provides step-by-step, end-to-end procedural guidance on how to perform the most common developer tasks with the Application Setting Manager.

Note

The SharePoint Guidance Library's Application Setting Manager provides an API to read and write configuration settings. It does not provide a user interface (UI) to read and write these configuration settings at run time. To do this, you either can create a custom UI for the Application Setting Manager or you can use a general purpose property bag editor. For example, on CodePlex, there is a community-driven effort to create a property bag editor that allows you to change the raw property bag values.