Reference Implementation: The Sandbox Execution Model

Many rich SharePoint applications can run within the confines of the sandbox. One of the most common scenarios for custom development in a SharePoint environment is the aggregation of data from several different lists within the same site collection. The Sandbox Reference Implementation (Sandbox RI) uses this scenario to illustrate a reasonably complex application that can run as a sandboxed solution.

The implementation highlights techniques and best practices in the following areas:

  • It demonstrates effective use of feature partitioning for reliable solution deployment.
  • It demonstrates the use of query objects to retrieve data from multiple lists.
  • It demonstrates the use of the Model-View-Presenter (MVP) pattern in a Web Part to isolate business logic from the presentation layer and the underlying data source.
  • It demonstrates the use of the Constructor Injection pattern to isolate business logic from dependencies.
  • It demonstrates the use of an Exception Shielding pattern to stop unhandled Web Part errors that prevent the host page from loading.

Solution Scenario

In this example, suppose you are providing consultancy services to a pharmaceutical company named Contoso Inc. Contoso has production plants in several locations, each of which has several departments, including Design, Maintenance, and Construction. Each department has a separate team site on your SharePoint 2010 intranet portal within the production plant site collection. Among other things, each department uses its individual team sites to keep records of statements of work (SOWs) and cost estimates provided to clients tracked against a central list of projects for the plant. Each project can have one or more SOWs associated with it.

The general manager for the Springfield production plant, Janet Schorr, wants to be able to monitor the progress of SOWs and estimates across all departments within the plant. However, the central IT team at Contoso headquarters is reluctant to permit farm solution deployments. To meet Janet's requirements, you implement a sandboxed solution that retrieves details of SOWs and estimates from each team site. The solution presents key details of these SOWs and estimates in a Web Part on the landing page of the Manufacturing site collection, as shown in the following illustration.

The Aggregate View Web Part


Deploying the Sandbox RI

The Sandbox Reference Implementation (Sandbox RI) includes an automated installation script that creates a site collection, deploys the reference implementation components, and adds sample data. After running the installation script, browse to the new Manufacturing site collection at http://<Hostname>/sites/Manufacturing. You can open and run the solution in Visual Studio, but this does not create a site collection or add sample data. To see the system fully functioning, you must run the installation script. The following table summarizes how to get started with the Sandbox RI.


The Auto-retract after debugging property is disabled for this Visual Studio project. This prevents Visual Studio from retracting the solution if you choose to step through the code. For more information about auto-retract, see Developing SharePoint Solutions.



Where can I find the Sandbox RI?

<install location>\Source\ExecutionModel\Sandboxed

What is the name of the solution file?


What are the system requirements?

SharePoint Foundation 2010

What preconditions are required for installation?

  • You must be a member of SharePoint Farm Admin.
  • You must be a memberof the Windows admin group.
  • SharePoint must be installed at http://<Hostname:80>. If you want to install to a different location you can edit these settings in the Settings.xml file located in the Setup directory for the solution.
  • SharePoint 2010 Administration service must be running. By default, this service is set to a manual start. To start the service, click Start on the taskbar, point to Administrative Tools, click Services, double-click SharePoint 2010 Administration service, and then click Start.

How do I Install the Sandbox RI?

Follow the instructions in the readme file located in the project folder.

What is the default installation location?

http://<Hostname>/sites/ Manufacturing

(This location can be altered by changing the Settings.xml in the Setup directory.)

How do I download the Sandbox RI?

The Sandbox RI is included in the download Developing Applications for SharePoint 2010.