[SharePoint 2010] Sandboxed Solution (Sandbox solution)

Source: Internet
Author: User
Tags visual studio 2010

Now in the SharePoint 2007 system, if we want to install the customized code into the system, we have to make a solution package (solution), and then in the central management of the system in the back of the console, the entire server farm was released. The best way to use the solution package is to solution the customized code in a single server environment in one-to-many servers. However, now the solution package can access the resources on each server, and we usually give very high licensing or take it to the global Assembly cache for ease of reference. " For the system of the whole, the traditional solution package is unsafe.

Why do we need sandbox solutions?

Now in the SharePoint 2007 system, if we want to install the customized code into the system, we have to make a solution package (solution), and then in the central management of the system in the back of the console, the entire server farm was released. The best way to use the solution package is to solution the customized code in a single server environment in one-to-many servers. However, now the solution package can access the resources on each server, and we usually give very high licensing or take it to the global Assembly cache for ease of reference. " For the system of the whole, the traditional solution package is unsafe.

In the new version of SharePoint 2010, we can make a fresh solution: sandbox solutions. The sandbox solution's scope is limited to a site collection Web site collection. Is safer for the whole system. Management, the sandbox solution can be collection by the site Manager to upload to solution gallery and to activate or stop. These do not need to be installed by the traditional server farms farm manager. So, each team can make its own sandbox solution and install it, and these sandbox solutions will not affect other team programs, "he has to do the same thing."

What types of SharePoint 2010 developers are supported by the sandbox solution?
    • Content Types, Site Columns
    • Custom Actions
    • Declarative Workflows
    • Event Receivers, Feature receivers
    • InfoPath Forms Services, JavaScript, AJAX, JQuery, Silverlight
    • List definitions
    • Non-visual Web Parts
    • Site Pages
    • SharePoint Online
How does the sandbox solution work?

In the new SharePoint 2010 system, the sandbox solution is executed through a service called Microsoft SharePoint Foundation Sandboxed Code service, which you can manage in the back-end interface, Select System settings->manage Services on server to locate it.

In the SharePoint 2010 installation path, you can also see a User under%program file%\common Files\Microsoft Shared\Web Server Extension\14 The code folder, which has three programs, is responsible for the sandbox solution, which is divided into:

    1. SPUCHostService.exe:
      The main Windows service, installed on each server farm server, can be managed through the service management interface.
    2. SPUCWorkerProcess.exe:
      A background program that actually performs a sandbox solution.
    3. SPUCWorkerProcessProxy.exe:
      This is a new generation of SharePoint 2010, the Service Application (Service Application) Agent interface program (proxy). The outside world is going to call SPUCWorkerProcess.exe through this agent interface program.



In the sandbox solution you can call Microsoft.SharePoint local functions. The functions that can be called are:

    1. microsoft.sharepoint 
      • spsite structure
      • spse Curity Object
      • Spworkitem and Spworkitemcollection object
      • spalertcollection Add method
      • Spalerttemplatecoll Ection the Add method
      • spusersolution and Spusersolutioncollection object
      • sptransformutilities category
    2. Li>microsoft.sharepoint.navigation
    3. microsoft.sharepoint.utilities  (except below)
      • sputility SendEmail method
      • sputility Getntfullnameandemailfromlogin method
    4. Microsoft.SharePoint.Workflow
    5. microsoft.sharepoint.webpartpages 
      • SPWebPartManager Object
      • spwebpartconnection object
      • WebPartZone object
      • WebPartPage object
      • ToolPane Objects
      • ToolPart Object

In the area of security policy, the Code Access security has also made some restrictions, taking local trust rather than full trust, and the three main allowable security policies are:

    1. Sharepointpermission.objectmodel
    2. Securitypermission.execution
    3. Aspnethostingpermission.level = Minimal

If you want to have a fully trusted setup to use important resources, you can create your own service Application (service application), which has a fully trusted setup. Then open an Agent interface (proxy) and let the sandbox solution pass through the Call Agent interface (proxy).

How do I make a sandbox solution?

To create a sandbox solution, you can set up a project for SharePoint 2010 in Visual Studio 2010, and if the type of the project can be done with a sandbox solution. Then the system will let you choose to create a sandbox solution or a general server farm solution. In the following example, we are going to create a sandbox solution that contains a custom Action, which can be found in the Site Action's menu, to discover the web link of YouTube.

First, in Visual Studio 2010, create a blank SharePoint 2010 case, and the. NET framework version will be selected for the 3.5 version. Next, Visual Studio 2010 will ask you to create a sandbox solution or a generic server farm solution. After the project has started, you can also change the type of the solution in the specialized window. This can be used as a generic server farm solution.


In the new project, we need to add a new Feature, which is the step to right-click on the features and select Add Feature. The next step is in the project. The next step is to add a blank element file, and we can add a new item to the project by right-clicking on it, and select the blank element file in the dialog box. Next, in the blank element file, fill in the following example program, and he will create a site action item to link to YouTube.




Next, you will be able to do the work of the programme. This time you will see the browser being opened, and the sandbox solution we made will appear in site Collection administration->solution, and the state is initiated. In fact, Visual Studio 2010 is the package of your project as a file named. wsp Sandbox solution, and then upload it to solution gallery. To the formal environment, just put this

The. wsp file is solution Gallery in the site collection management interface.

Next you can go to the site Action menu to find out what we are adding to and test whether it will connect to YouTube.

What are the limitations of sandboxed solutions?

The main limitations of the sandbox solution are the following three items:

    • Ability to perform local microsoft.sharepoint only
    • Code Acess Security Policy restrictions
    • Custom API Closure Checklist
The first and second paragraphs in the preceding paragraph have been explained and provided by the micro-software. The third part is for us to do our own maintenance. We can easily and easily maintain the effect of the restriction. The sandbox solution is performed in the state of local trust, with two modes of doing it:
    • The machine mode
      1. In the Web site front-end of the main machine
      2. Lower Management
      3. Poor extension capability
    • Remote-mode
      1. On the back of the machine.
      2. The effect of balancing the load can be achieved
If you really need access to full trust to access the resources, we can create a service application (service application) to access full trust to access the resources, this service application (service application) to release a proxy interface ( Proxy) Let our sandbox solution go to the call, so that we can execute full trust to do things. To create such a service Application (service application) and Agent interface (proxy), the steps are as follows:
    • Inheriting Spproxyoperationargs to establish his own args category
    • Inheriting spproxyoperation to build operation and copy the Execute method
    • Register your Service Application (Service application)
    • Sandbox solution, through sputility.executeregisteredproxyoperation () Call Agent interface (proxy)
How do I manage sandboxed solutions?

With the management of the sandbox solution, you can do the absolute restriction of the resources on the server farm farms, or lock a

Sandbox solutions and so on. At the site collection sites collection We can use the resource's control.

The location of the lock sandbox solution and the resource balance load settingCentral Administration Page->system settings->manage User Solutions.

The Resource usage cap is located in: Central administration page->application management->configure quotas and locks.

The sandbox solution is a revolutionary design for SharePoint, and different teams can perform their own sandbox solutions, and they don't interact with each other at all. " It brings security and convenience.

[SharePoint 2010] Sandboxed Solution (Sandbox solution)

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.