Sandbox Solutions

On this page you read:


Common Error on Sandbox Solution Build

While building sandbox solutions for SharePoint 2010 using Visual Studio 2010, if you find an error in deployment “Error occurred in deployment step 'Retract Solution': Cannot start service SPUserCodeV4 on computer ‘servername’, you need to start “Microsoft SharePoint Foundation Sandboxed Code Service”.
To do so you will need to follow the steps below:

Go to Central Admin > Service Application > Manage services on server
Locate and activate service Microsoft SharePoint Foundation SandBox Code Service


  1. Sandboxed Solutions are solutions that run in the context of a site collection. Hence they are restricted.
  2. User must be site collection administrator to be able to deploy sandbox solutions.
  3. Sandbox assemblies run under a separate service: SPUserCodeV4
  4. Sandbox solutions cannot connect to resources that are not on the local server, access a database, call unmanaged code, write to the system disk, or access resources in a different site collection.
  5. Sandbox solutions have the capability to monitor and shut down applications.
  6. Default CAS: No Call to web service, No file I/O, limited access to SharePoint Object Model
  7. No Support for WebPart derived form Microsoft.SharePoint.WebPartPages.WebPart, Only System.Web.UI.WebControls.WebPart webparts are supported.
  8. The assemblies is written to the disk at C:\ProgramData\Microsoft\SharePoint\UCCache in Sandbox Solutions rather than GAC
    Note: Some times although you have deployed sandbox solution, you can not find the assemblies in directory mentioned above (UCCache). And only after you add the WebPart to a page or load a page which already has that WebPart on you will be able to view related assembly under that path.
  9. Why using Sandbox solution rather than Farm ones:
    • More secure (i.e. they are ristricted to what they can do, do not touch file system even during deployment)
    • Rapid Deployment
    • Skip Application pool recycle
    • Extensible Solution validation framework
    • Can be monitored
    • Allow more manageable Hosting scenarios
    • The can be extended using full trust proxies.
    • Delegate deployment to site owner (due to Sandboxed solution cannot bring down a farm)
Sample: A simple sample code for creating a basic WebPart via Sandbox solution can be found here