Sandbox Solutions Architecture

http://msdn.microsoft.com/en-us/library/ee539417.aspx

A sandboxed solution goes through four phases.

An upgrade for a sandboxed solution is any solution that is uploaded to the Solution Gallery with the same solution identifier (ID)
of the version deployed to the site collection but with a different
hash code
.

Sandbox’s security access policy:

* SharePointPermission.ObjectModel
* SecurityPermission.Execution
* AspNetHostingPermissionLevel = Minimal

*** Static members are not supported when developing a sandboxed
solution. If an object is available in a sandboxed solution, do not use that object in a static variable.

Memory usage is tracked by a maximum consumption during execution, whereas CPU execution time and database query time are based on a stopwatch-based measure of time during execution

CPU Execution Time – One element of monitoring is to ensure that sandboxed solutions do not occupy too much CPU execution time and to track how much execution time the code consumes. You can track this by using a stopwatch-based measure. The usage is recorded and associated with the site collection and solution.

Memory ConsumptionMemory consumption is tracked so that abnormal usage of memory is limited. The tracking is done on a per-process basis.

Database Query TimeThis measure calculates the aggregated stopwatch-based time that is spent any time SharePoint Foundation performs an internal query to the back-end database.

Abnormal TerminationAbnormal termination represents a penalty that is given to an assembly group if the process or application domain where it resides is terminated for exceeding a hard threshold. This measure is an aggregate measure that double penalizes any assembly group that causes a process termination.

Critical ExceptionA critical exception is any exception that causes termination of the process. When this happens, the information is aggregated for all assembly groups inside an application domain and given a server resource penalty.

  • Critical exceptions include the following:
  • ThreadAbortException
  • OutOfMemoryException
  • AccessViolationException
  • AppDomainUnloadedException
  • BadImageFormatException
  • TypeInitializationException
  • MissingMethodException
  • ExecutionEngineException

Unhandled ExceptionsUnhandled exceptions are any exceptions that are not captured during code execution. In general, unhandled exceptions are treated as a problem with the hosted code. Administrators can factor these problems into the general resource calculation formula.

Data Marshaling SizeA sandboxed solution could potentially marshal too much data from the front-end Web server that, in turn, can cause server delays. To prevent this, there is an upper limit on the amount of data that can be marshaled.


Solution Validation Framework

SharePoint Foundation includes a solution validation framework. An assembly within an activated sandboxed solution cannot run without completely passing validation. The framework includes extensibility to create your own solution validators. The validation framework includes a solution validation callout in the object model. The following objects are included:

Each validator for a solution must include a signature. The signatures of all validators for a solution are used to create a validator hash code. When all validations are successful, the hash code is attached to the solution. If the hash code of the current solution validators and the hash code associated with the solution do not match for any reason, all validators are run again. There are two ways that the hash code of the current validators can change and cause a revalidation of the solution:

  1. Validator was added or removed.
  2. Validator signature has changed.

In order to signal that a validator has changed, the developer must change the signature to enforce a revalidation. It will not be automatically detected if a strong name or assembly changes.

Capabilities and Elements in Sandboxed Solutions


The following capabilities and elements are available in sandboxed solutions:

The following capabilities and elements are not available in sandboxed solutions:

  • Custom Action groups
  • HideCustomAction element
  • Content Type Binding
  • Web Application-scoped Features
  • Farm-scoped Features

Site Templates in Sandboxed Solutions (not supported; use WebTemplate instead)

Site template files (.stp) and site definitions, in the form of WebTemp.xml files, are not supported in sandboxed solutions. In order to support similar functionality, a new Feature element called WebTemplate was added. When a Feature that contains the WebTemplate element is activated, the site template appears in the list of available site templates.

Web Parts in Sandboxed Solutions

Sandbox solution’s web part must build on top of System.Web.UI.WebControls.WebParts.WebPart rather than Microsoft.SharePoint.WebPartPages.WebPart class.

Web Part connections are not supported in sandboxed solutions. – NO CONNECTABELE WEBPARTS!!!

Asynchronous postbacks in Web Parts in sandboxed solutions are not supported

Web Parts must still be declared as a safe control in the solution package and must have the AllowPartiallyTrustedCallers attribute set at the assembly level. (see below)


Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: