Developing Sandbox Solutions

  • 3,629 views
Uploaded on

My Session in SPS Arabia - March 2010 …

My Session in SPS Arabia - March 2010
Provides an overview about SharPoint 2010 Sandbox Solutions.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • SharePoint Sandbox Solutions Presentation
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
3,629
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
1
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • This chronicles the process of using a custom "bugs" Web Part and solution in a particular site.The SPSite adminuploads a new solution package (*.wsp) into the Solution Gallery of the SPSite. The SPSite admin"activates" the solution.  This activates the features within the solution.  Web Part files are copied into the Web Part gallery.As part of the activation, solution is validated using the validation framework. Custom validator can be added for example to check that only solutions signed with certain key can be activated. Customers and partners can develop their own validators based on their needs.Some time later, a user decides to add a Web Part to their home page.  They go into Web Part edit mode, and click "Add a Web Part".  They notice the additional Web Part options, and click Add. SharePoint now checks to see if the bugs.dll file, which backs this Web Part, is installed into the assembly cache.  It is not. The assembly is faulted into the assembly cache; it is extracted and copied from the solution file to temporary folder in disk and loaded to memory (disk is cleaned immediately). Now the Web Part is about to be used. It is loaded into Sandbox Code service host.Processes deliver the Web Part to be executed to the service.
  • An incoming request comes in for a page with a Web Part from a partial trust assembly.   This is delegated to a Web Part proxy.  The Web Part proxy then in turn calls the worker process manager, and tells it to execute the Web Part. The worker process manager queries the configuration database to figure out which machine and process it should send the request to. The worker process then sends the request to the user code manager on that machine. The user code manager needs to ensure that the assembly backing the Web Part is locally deployed.  To do this, it reaches back into the Web Part solution package, extracts the assembly, and places it into the assembly cache. Now, the SPUserCodeManager (SPUserCodeHostService.exe) delegates the request to execute the code to SPUserCodeWorkerProcess.exe. The full trust Web Part wrapper works with the instantiated process to simulate the Web Part lifecycle.  The Web Part itself calls into the SharePoint OM to retrieve some set of data. The resulting HTML and viewstate changes are bubbled back to the hosting process, which has been synchronously waiting for this infrastructure to complete. The resulting page is sent back to the user.Rendered results sent back to the requester.

Transcript

  • 1. Developing Sandbox Solutions
    Mohamed Yehia
    March 2010
  • 2. Ana Meen?
    Technical Architect
    www.mohamedyehia.net
    @mohdyehia
    myehia@live.com
  • 3. Outline
    Challenges
    What are Sandbox Solutions?
    How do they work?
    What can I do them Sandbox Solutions?
    How can they be managed?
    Best Practices
    Points to Consider
    References
    Q&A
  • 4. Challenges
    Dev, Admin Fight!
    Change production farm to Full 
    Memory Leaks
    Update web.config files
    Bad code that eats up farm resources
    Deploy everything to the GAC
    Admins have some control using CAS
    Difficult to implement
    Difficult to get right
    Largest cause of SharePoint Support cases
  • 5. Sandbox Solutions
    Executes in a sandbox – a separate process
    Controlled by CAS
    Subset of Microsoft.SharePoint namespace
    Deployed by Site Owners from Solution gallery
    Can be monitored by Farm Administrators
  • 6. Why?
    More secure
    Rapid deployment
    Skip application pool recycle
    Extensible Solution validation framework
    Can be monitored
    Allow more manageable Hosting scenarios
    Do not touch file system
    Delegates deployment to Site Owners
  • 7. demo
    Developing a Sandbox Solution
    Sandbox vs. Farm Solutions
  • 8. Sandboxed Solutions Execution
    2
    1
    5
    6
    7
    4
    3
    Per-WFE AssemblyCache
    RootSPWeb of SPSite
    <siteguid>company.intranet.webpart.wspcompany.intranet.dll
    Solution gallery
    Web Part gallery
    Sandboxed Code Serice
    WebParts.wsp
  • 9. Sandbox Solution Processes
    Under SharePoint RootUser Code
    SPUserCodeHostService
    Manages Sandbox solutions
    SPUserCodeWorkerProcess
    Sandbox
    Executes partially trusted code
    SPUCWorkerProcessProxy
    Proxy service used by web application
  • 10. Sandbox Solution Restrictions
    No SPSecurity
    No SPSite constructor
    Site Collectionis the limit
  • 11. Supported In Sandbox 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
  • 12. Not Supported In Sandbox Solutions
    SharePoint
    Custom Action groups
    HideCustomAction element
    Content Type Binding
    Web Application-scoped Features
    Farm-scoped Features
    CustomPropertyToolPart Class
    Programmatic workflow
    Event receivers
    SPLimitedWebPartManager
    Timer jobs
    visual WebParts
    SharePoint mapped folders (e.g. "_layouts", and "images")
    .Net
    ADO.NET
    System.IO
    System.Security.Cryptography
    System.Web.UI.ClientScriptManager
  • 13. demo
    What’s not allowed?
  • 14. Managing Sandbox Solution
    Activate User Code Service
    Load Balancing
    Local
    Run on WFE
    Remote
    Dedicated servers
    Specify Quotas
  • 15. Sandbox Solution Monitoring
    Part of Site Collection Quota
    Across all sandbox solutions in the site collection
    Each measure defines:
    Resource Per point
    Absolute Limit
    Reset daily
  • 16. Sandbox Solution Monitoring
    14 Metrics
    AbnormalProcessTerminationCount
    CPUExecutionTime
    CriticalExceptionCount
    InvocationCount
    PercentProcessorTime
    ProcessCPUCycles
    ProcessHandleCount
    ProcessIOBytes
    ProcessThreadCount
    ProcessVirtualBytes
    SharePointDatabaseQueryCount
    SharePointDatabaseQueryTime
    UnhandledExceptionCount
    UnresponsiveprocessCount
  • 17. demo
    Managing and Monitoring Sandbox Solutions
  • 18. Validating Sandbox Solutions
    Deployed as Farm Solutions
    Runs when solution is activated or changed
    All validators run an all solutions
    Inherit from SPSolutionValidator class
    Override
    ValidateSolution
    ValidateAssembly
  • 19. demo
    Validating Sandbox Solutions
  • 20. Full Trust Proxies
    Designed to overcome Sandbox API restricution
    Deployed as Farm Solution
    Inherit from
    Microsoft.SharePoint.Usercode.SPProxyOperation
    Microsoft.SharePoint.Usercode.SPProxyOperationArgs
    Consume the proxy using
    SPUtility.ExecuteRegisteredProxyOperation
  • 21. Wrap Up
    Consider Sandbox Solutions first
    Safe
    Monitored
    Allow more manageable hosting scenarios
    Be creative with your solution design
    Site Collection and below
  • 22. Considerations
    Use Silverlight + WCF instead of Full Trust Proxy
    Need to upgrade all copies of the solution across all site collections
    Quotas are for all sandbox solutions in the site collection
    Wait and see
    Further Improvement
    Quota for each solution
    Define validators on the site collection
  • 23. References
    Sahil Malik (blah.winsmarts.com / @sahilmalik)
    Dave Milner (www.davemilner.com/@davemilner)
    SiriniSistla (@ sirinisistla)
    SharePoint 2010 Sandboxed Solution
    Paul Stubbs
    Developing, Deploying, and Monitoring Sandboxed Solutions in SharePoint 2010 – MSDN Magazine
    www.sharepointdevwiki.com
  • 24. Thanks
    Stay tuned for
    • Next Gathering
    • 25. SharePoint 2010 Community Launch on May 12th
    www.mohamedyehia.net
    @mohdyehia
    myehia@live.com