Tuesday, March 27, 2012

Sandboxed solution: Error occurred in deployment step 'Activate Features'

Symptom(s)

While deploying a sandbox solution to SharePoint 2010 via visual studio 2010, user may receive following error:

Error occurred in deployment step 'Activate Features': Timeout occurred while running the SharePoint Sandboxed Code service. This service is required to run sandboxed solutions in SharePoint. Please ensure the service is configured correctly in SharePoint.


Assumption(s)
  1. Sandboxed solutions enabled on the SharePoint farm
  2. User have appropriate access rights(s)

Cause
Above mentioned error is generally caused when a deployed solution can't be activated (see the background section below for more info) because the host process, which execute sandboxed solutions, didn't respond in expected time frame.

The host process is:
  • Referred as  "Microsoft SharePoint Foundation Sandboxed Code Service" when seen in SharePoint UI (via Central Admin)
  • Referred as "SharePoint 2010 User Code Host" when seen in Windows "Services"  (under administration services)
Resolution
You can use either the SharePoint UI or Windows "Services" console (both refer to the same thing)
  • If the service is not running, start the service.
  • If the service is already running, re-start the service (i.e. stop and start)
Background
During deployment of solution via VS2010, visual studio may do following:
  1. Builds a solution:
    • Compile the code
    • Package (aka build) code into a wsp solution,
  2. Deploy the solution:
    • Retract existing version of the solution (optional - only if previous version exist)
    • Uploads the solution file (.wsp file)
      • if "farm solution" - uploaded to the farm visible via central admin
      • If "sandboxed solution" - uploaded to the solution gallery of the site collection where it will be activated in the next step.
    • "deploy" (make it available to web applications):
      • In case of sandbox solution, uploading the solution file constitute "deploying"
      • If farm solution, Visual studio specify the "web application" (web application hosting the targeted site collection) for deployment, and interacts with timer job for immediate deployment.
  3. IIS Reset: If solution is Farm solution, VS2010 try to do an IIS reset.
  4. "Activate Features": In order to make the functionality consumable at site collection level, the feature needs to be turned on. In this step visual studio try to activate the feature at appropriate site collection.



2 comments: