SharePoint Sandboxed Solutions

Source: Internet
Author: User
Tags visual studio 2010

From: http://www.sharepointdevwiki.com/display/sp2010/SharePoint+Sandboxed+Solutions

 

Sandboxed solutions also offer a way to build SharePoint Web Parts and deploy them to a site without needing administrative intervention --- that is, you can deploy a Web Part to a SharePoint site and have it run in the context of that site either in an on-premises instance of SharePoint or in the cloud using the hosted version of SharePoint.

Some of the key takeways from the session at # SPC09 were that Sandboxed Solutions are the preferred approach for all WSP deployment scenarios. the only reason NOT to use them is where it doesn't support what you are doing.

 

"Any solution that is created for Sandbox can be deployed into a special Solutions Gallery in the site-collection called solutions gallery. and all these solutions that are deployed here can be activated from a menu (ECB menu) on that solutions gallery itself, hover around the item and you will get a ACTIVATE/DEACTIVATE menu. for all this to work properly we have to make sure that the "Microsoft SharePoint Foundation User Code Service" is starting on one or more of the servers in the Farm. you can confirm whether the service is running or not by checking the sandbox resource quota that is available on the top of the same page (Solutions Gallery Page ). all of the resource assignment and monitoring for the Sandboxed solution can be controlled from Central Admin app.
Sandboxed Solutions to work need these 3 thing:

  • User Code Service (SPUCHostService.exe): this service will decide whether the box on which this service is running will particle in the Sandboxed solutions are not. this shoshould run either on one box or more for sandbox solutions to take advantage of the server and run it on that server.
  • Sandbox Worker Process (SPUCWorkerProcess.exe): This is the actual process in which the Sandboxed Solutions run.
  • Sandbox Worker Process Proxy (SPUCWorkerProcessProxy.exe): If you have already studied and are aware of the new Service Application architecture then you get this one, this is the proxy which the web-app will use form the proxy group to use the sandbox."
    INTRO: Sandboxed Solutions in SP2010
10 reasons to use Sandboxed Solutions
  • Sandboxed solutions are secure.
  • Sandboxed solutions can be monitored.
  • Sandboxed solutions do not affect other sandboxed solutions, well atleast not in other site collections is what I mean.
  • Sandboxed solutions do not touch the file system for the most part
  • Sandboxed solutions skip application pool recycles, so debugging is not such a pain.
  • Sandboxed solutions allow the site collection administrator to perform deployment and upgrades
  • Sandboxed solutions make CAS into ies look like the out of style hairstyles of 1980 s
  • The Solution validation framework for sandboxed solutions is exntensible, simply inherit from the SPSolutionValidator base class.
  • Sandboxed solutions remove the need for line by line code reviews
  • Sandboxed solutions allow you to offer different level of SLAs to different site collections using Resource Quotas.

Source: Sahil Malik

What is supported by sandboxed solutions?

Basically it is a narrowed down subset of the SharePoint OM. this is controlled with VS2010 by selecting your Visual Studio project as a sandboxed solution. it will hide any methods/classes that are not available automatically.

The following capabilities and elements are available in sandboxed solutions:

  • List definitions
  • List instances
  • Onet. xml
  • WebTemplate Feature element instead of Webtemp. xml
  • Content Types/Fields
  • Navigation
  • Module/files
  • Feature callouts
  • Web Parts derived from WebPart
  • Event receivers
    • SPItemEventReceiver
    • SPListEventReceiver
    • SPWebEventReceiver
  • Custom Actions
  • Workflows
What is not supported by sandboxed solutions?

The following capabilities and elements are not available in sandboxed solutions (from MSDN ):

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

(Not on MSDN)

  • Programmatic workflow
  • Event receivers
    • SPLimitedWebPartManager
  • Timer jobs
  • Visual WebParts
  • SharePoint mapped folders (e.g. "_ layouts", and "images ")

The following. NET namespaces are not supported by sandboxed solutions:

  • ADO. NET
  • System. IO
  • System. Security. Cryptography
  • System. Web. UI. ClientScriptManager
Solution Monitoring

Administrators can monitor a solution and set a quota for how many "resource points" it can use in a day. There are varous measures that build up points for a solution.

Add-PSSnapin Microsoft.SharePoint.Powershell[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")$s=[Microsoft.SharePoint.Administration.SPUserCodeService]::Local$s.ResourceMeasures \| Select-Object Name,ResourcePerPoint
Server Default

The default quota is 300 resource points a day, if you exceed that your solution is "cut off ". the below table shows how does instances of a resource measure it takes to build a resource point e.g. 1 "AbnormalProcessTerminationCount" is one resource point, so 300 of these wowould "cut off" the solution.

Measure Resource Per Point
AbnormalProcessTerminationCount 1
CPUExecutionTime 3600
CriticalExceptionCount 10
InvocationCount 100
PercentProcessorTime 85
ProcessCPUCycles 100000000000
ProcessHandleCount 10000
ProcessIOBytes 0
ProcessThreadCount 10000
ProcessVirtualBytes 0
SharePointDatabaseQueryCount 20
SharePointDatabaseQueryTime 120
UnhandledExceptionCount 50
UnresponsiveprocessCount 2
Solution Validators

Allow valim validation of a solution, installed at the farm scopeInstalled in a FeatureActivated eventOnce deployed, when you attempt to deploy a solution that breaks a validation rule, an error is displayed.

External References
  • Sandboxed Solutions Architecture-MSDN
  • Visual Studio 2010 Tools for SharePoint Development
  • SharePoint Application Life Cycle Management Presentation at SPSNYC
  • Sandboxed Solutions and Security in WSS 4.0 Partial trust or "Sandboxed" solutions (20Oct09)
  • SharePoint 2010: Sandboxed Solutions
  • INTRO: Sandboxed Solutions in SP2010
  • PowerShell command to get Resource Count for SP 2010
  • SharePoint 2010's Sandboxed Solutions
    Good article by Paul Stubbs
  • Developing, Deploying, and Monitoring Sandboxed Solutions in SharePoint 2010-MSDN
    Paul Stubbs is obviusly the main man at Microsoft for Sandboxed Solutions and pumping out a heap of info on this!
  • Why NOT to use SandBoxed Solutions-by Chris Givens
  • Channel 9-MSDN-Sandboxed Solutions webcasts
    Great web casts on Sandboxed solutions!
  • SharePoint 2010 Sandbox Solutions are Bad
    Great post by Doug Ware on why not to use them

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.