The SharePoint Guidance Library
The SharePoint Guidance Library is a collection of reusable code-based utilities that address common challenges in application development for the SharePoint platform. You can use these components in your own SharePoint applications to help you improve your development speed and follow best practice guidance. The SharePoint Guidance Library consists of three key components:
- The SharePoint Service Locator provides a simple implementation of the service location pattern for SharePoint applications. This enables you to isolate your code from dependencies on external types, which makes your code more modular, easier to test, and easier to maintain.
- The Application Setting Manager provides a robust and consistent mechanism for storing and retrieving configuration settings at each level of the SharePoint hierarchy, from individual sites (SPWeb) to the entire server farm (SPFarm).
- The SharePoint Logger provides easy-to-use utility methods that you can employ to write information to the Windows event log and the SharePoint Unified Logging Service (ULS) trace log. It also enables you to create custom diagnostic areas and categories for logging.
To get started with the SharePoint Guidance Library, we recommend that you read Application Foundations for SharePoint 2010. It puts each component in the SharePoint Guidance Library into context and provides detailed information on using each component.
Deploying the SharePoint Guidance Library
The SharePoint Guidance Library is distributed as source code. To build and install the library, you must open and build the Microsoft.Practices.SharePoint solution in Microsoft Visual Studio® 2010. This will create the Microsoft.Practices.SharePoint.Common assembly, which includes all three library components.
To use the SharePoint Service Locator, you must also deploy the Microsoft.Practices.ServiceLocation assembly to the global assembly cache. This assembly defines the common service locator interfaces on which the SharePoint Service Locator is developed. The Microsoft.Practices.ServiceLocation assembly is included in this release as a compiled assembly.
The end user license agreement for the Developing Applications for SharePoint 2010 release permits you to include and distribute these assemblies within your SharePoint solutions.
System Requirements
To build the SharePoint Guidance Library, your development environment must include Visual Studio 2010 Professional Edition or higher and any version of SharePoint 2010, including SharePoint Foundation 2010. The SharePoint Guidance Library is compatible with all versions of SharePoint 2010, including SharePoint Foundation 2010.
Using the SharePoint Guidance Library in Sandboxed Solutions
SharePoint 2010 introduces a new restricted execution environment—known as the sandbox—that allows you to run partially trusted solutions in a strictly controlled environment within the scope of an individual site collection. The sandbox environment limits the APIs that can be used by code contained in a sandboxed solution, and restricts a sandboxed solution to the resources of the site collection where it is deployed. Wherever possible, the SharePoint Guidance Library components include enhancements that enable them to run within the sandbox environment. Certain capabilities, such as logging and tracing, are not possible within sandboxed solutions as the security restrictions of the environment do not permit these activities. For these scenarios, the SharePoint Guidance Library provides full trust proxies—which must be installed by a farm administrator—to deliver the capability. The SharePoint Guidance Library also provides several extensibility points where the existing logic can be replaced by an approach that can be used within the sandbox—for example, by logging events to a list within the site collection, rather than through the SharePoint APIs. You will find more details on the capabilities and limitations of the SharePoint Guidance library within the sandbox environment in the chapter Application Foundations for SharePoint 2010.
