Microsoft.SharePoint.dll APIs That Are Available from Sandboxed Solutions

This topic provides guidance about which APIs in the Microsoft.SharePoint.dll assembly can be called from code in a sandboxed solution.

Applies to: SharePoint Foundation 2010

Available in SharePoint Online

Calls from sandboxed solutions to APIs in SharePoint assemblies, other than Microsoft.SharePoint.dll, are subject to the same restrictions as any other calls from sandboxed solutions: Only assemblies with the AllowPartiallyTrustedCallersAttribute can be called, and only assemblies in the global assembly cache can be called. All APIs that are called are subject to the code access security (CAS) policy and the restricted security token of the sandboxed worker process. For more information, see Restrictions on Sandboxed Solutions in SharePoint 2010 and Available and Unavailable SharePoint Assemblies from Sandboxed Solutions in SharePoint 2010.

Warning

The Sandbox Solution framework provides a mechanism for executing user-provided code outside of the IIS worker process. The Sandbox Solution framework should not be used as a mechanism for enforcing security boundaries when executing user code. Sandbox Solutions are not supported as a security boundary with user code, especially code of unknown origin. We advise against executing Sandbox Solutions of unknown origins.

The Microsoft.SharePoint.dll assembly is a special case. Calls from sandboxed solutions to APIs in this assembly are both more and less restricted than calls to other SharePoint APIs.

  • Only a subset of the APIs in Microsoft.SharePoint.dll are available in sandboxed solutions.

  • However, those APIs that are available run in a special, fully trusted process and therefore are not subject to the restrictions of the sandboxed worker process. For example, the GetLocalizedString method can be called from a sandboxed solution even though it reads from the disk, something that is not allowed by code that actually runs within the sandboxed worker process.

  • Certain methods in Microsoft.SharePoint.dll can be called in sandboxed solutions only if the calling code conforms to certain restrictions on the values of the passed parameters. Also, certain properties in Microsoft.SharePoint.dll are read/write in farm solutions but read-only in sandboxed solutions. For more information, see Methods and Properties That Are Available with Restrictions later in this topic.

Microsoft.SharePoint.dll Namespaces That Are Available in Sandboxed Solutions

Classes That Are Available in Sandboxed Solutions

Methods and Properties That Are Available with Restrictions

Microsoft.SharePoint.dll Namespaces That Are Available in Sandboxed Solutions

Each of the following namespaces has at least one class that can be called from a sandboxed solutions. The specific classes are listed in the tables in the next section.

  • Microsoft.SharePoint

  • Microsoft.SharePoint.Administration

  • Microsoft.SharePoint.Navigation

  • Microsoft.SharePoint.UserCode

  • Microsoft.SharePoint.Utilities

  • Microsoft.SharePoint.WebControls

  • Microsoft.SharePoint.WebPartPages

  • Microsoft.SharePoint.Workflow

Classes That Are Available in Sandboxed Solutions

Each of the following types has at least one member that can be called in a sandboxed solution. To find out whether a particular member is allowed in a sandboxed solution, view the SDK reference topic for the member. Near the top of the topic is an indication of whether it is available.

Warning

Do not create a static (Shared in Microsoft Visual Basic) field or property in code that runs in a sandboxed solution. Doing this is not supported.

Microsoft.SharePoint Namespace

DefaultItemOpen

DraftVisibilityType

NameValuePair

OfficialFileResult

PAGETYPE

SPAddFieldOptions

SPAlert

SPAlertCollection

SPAlertDeliveryChannels

SPAlertFrequency

SPAlertStatus

SPAlertTemplate

SPAlertType

SPAttachmentCollection

SPBaseCollection

SPBasePermissions

SPBaseType

SPBrowserFileHandling

SPBuiltInContentTypeId

SPBuiltInFieldId

SPBusinessDataField

SPCalendarType

SPCalendarViewStyle

SPCalendarViewStyleCollection

SPChange

SPChangeAlert

SPChangeCollection

SPChangeCollection.CollectionScope

SPChangeContentType

SPChangeField

SPChangeFile

SPChangeFolder

SPChangeGroup

SPChangeItem

SPChangeList

SPChangeQuery

SPChangeSecurityPolicy

SPChangeSite

SPChangeToken

SPChangeTokenCollection

SPChangeType

SPChangeUser

SPChangeView

SPChangeWeb

SPCheckedOutFile

SPCheckinType

SPChoiceFormatType

SPCompositeIndexableStatus

SPContentType

SPContentTypeCollection

SPContentTypeId

SPContentTypeUsage

SPContext

SPContextPageInfo

SPCopyDestination

SPCopyDestinationCollection

SPCopyDestinationType

SPCopyFieldInformation

SPCopyFieldMask

SPCustomizedPageStatus

SPCustomWebTemplate

SPDateTimeFieldFormatType

SPDistributionGroupException

SPDocTemplate

SPDocTemplateCollection

SPDocumentLibrary

SPDuplicateValuesFoundException

SPEmailEventReceiver

SPEndpointAddressNotFoundException

SPEventContext

SPEventHostType

SPEventPropertiesBase

SPEventReceiverBase

SPEventReceiverDefinition

SPEventReceiverDefinitionCollection

SPEventReceiverStatus

SPEventReceiverSynchronization

SPEventReceiverType

SPEventType

SPException

SPFeature

SPFeatureCollection

SPFeatureDefinitionScope

SPFeatureDependency

SPFeatureDependencyCollection

SPFeatureProperty

SPFeaturePropertyCollection

SPFeatureQueryResultCollection

SPFeatureReceiver

SPFeatureReceiverProperties

SPFeatureScope

SPField

SPField.ListItemMenuState

SPFieldAllDayEvent

SPFieldAllowEditing

SPFieldAttachments

SPFieldBoolean

SPFieldCalculated

SPFieldCallTime

SPFieldCallTo

SPFieldChoice

SPFieldCollection

SPFieldComputed

SPFieldConfidential

SPFieldConfirmations

SPFieldContactInfo

SPFieldCrossProjectLink

SPFieldCurrency

SPFieldDateTime

SPFieldDecimal

SPFieldDueDate

SPFieldFacilities

SPFieldFile

SPFieldFrom

SPFieldGuid

SPFieldIndex

SPFieldIndexCollection

SPFieldLink

SPFieldLinkCollection

SPFieldLookup

SPFieldLookupValue

SPFieldLookupValueCollection

SPFieldModStat

SPFieldMultiChoice

SPFieldMultiChoiceValue

SPFieldMultiColumn

SPFieldMultiColumnValue

SPFieldMultiLineText

SPFieldNumber

SPFieldPageSeparator

SPFieldRatingScale

SPFieldRatingScaleValue

SPFieldRecurrence

SPFieldSendTo

SPFieldText

SPFieldType

SPFieldTypeDefinition

SPFieldTypeDefinitionCollection

SPFieldUntil

SPFieldUrl

SPFieldUrlValue

SPFieldUser

SPFieldUserSelectionMode

SPFieldUserValue

SPFieldUserValueCollection

SPFieldValidationException

SPFieldValueException

SPFieldWhatsNew

SPFieldWhereabout

SPFieldWorkflowStatus

SPFile

SPFile.SPCheckOutType

SPFile.SPLockType

SPFileCheckOutException

SPFileCheckOutExceptionType

SPFileCollection

SPFileCollectionAddParameters

SPFileConversionResult

SPFileConversionState

SPFileLevel

SPFileLockException

SPFileLockExceptionType

SPFileSaveBinaryParameters

SPFileSystemObjectType

SPFileVersion

SPFileVersionCollection

SPFolder

SPFolderCollection

SPForm

SPFormCollection

SPGroup

SPGroupCollection

SPInvalidPropertyException

SPIssueList

SPIssueList.ReportType

SPItem

SPItemEventDataCollection

SPItemEventProperties

SPItemEventReceiver

SPLanguage

SPLanguageCollection

SPLink

SPLinkCollection

SPList

SPListCategoryType

SPListCollection

SPListDataSource

SPListDataValidationException

SPListDataValidationException.SPFailure

SPListDataValidationException.SPReason

SPListDataValidationException.SPValidationType

SPListEventProperties

SPListEventReceiver

SPListItem

SPListItemCollection

SPListItemCollectionPosition

SPListItemInfo

SPListItemVersion

SPListItemVersionCollection

SPListTemplate

SPListTemplate.QuickLaunchOptions

SPListTemplateCollection

SPListTemplateType

SPLocale

SPLocaleCollection

SPMember

SPMemberCollection

SPModerationInformation

SPModerationStatusType

SPModule

SPModuleCollection

SPMoveOperations

SPNumberFormatTypes

SPObjectType

SPOfficialFileAction

SPOfficialFileSubmissionMode

SPPermissionGroup

SPPermissionGroup64

SPPermissionInfo

SPPictureLibrary

SPPreviewValueSize

SPPrincipal

SPQuery

SPQueryThrottledException

SPRecycleBinItem

SPRecycleBinItemCollection

SPRecycleBinItemCollectionPosition

SPRecycleBinItemState

SPRecycleBinItemType

SPRecycleBinOrderBy

SPRecycleBinQuery

SPRecycleBinType

SPRegionalSettings

SPRelatedField

SPRelatedFieldCollection

SPRelationshipDeleteBehavior

SPResource

SPResourceScope

SPResourceType

SPRichTextMode

SPRoleAssignment

SPRoleAssignmentCollection

SPRoleDefinition

SPRoleDefinitionBindingCollection

SPRoleDefinitionCollection

SPRoleType

SPSearchResult

SPSearchResultCollection

SPSearchResultCollectionPosition

SPSecurableObject

SPServiceContext

SPSimpleItem

SPSite

SPSite.StorageManagementInformationType

SPSite.StorageManagementSortedOn

SPSite.StorageManagementSortOrder

SPSiteDataQuery

SPTemplateFileType

SPTimeZone

SPTimeZoneCollection

SPUrlFieldFormatType

SPUser

SPUserCollection

SPUserCustomAction

SPUserCustomActionCollection

SPUserCustomActionRegistrationType

SPUserCustomActionScope

SPUserResource

SPUserResourceCollection

SPUserSolution

SPUserSolutionCollection

SPUserSolutionStatus

SPUserStorage

SPView

SPViewCollection

SPViewCollection.SPViewType

SPViewFieldCollection

SPViewFlags

SPViewScope

SPViewStyle

SPViewStyleCollection

SPVirusCheckStatus

SPWeb

SPWebCollection

SPWebEventProperties

SPWebEventReceiver

SPWebListInfo

SPWebTemplate

SPWebTemplate.TeamCollaborationSiteConfiguration

SPWebTemplate.WebTemplate

SPWebTemplateCollection

SPXmlDocumentCollection

Strings

TriState

Microsoft.SharePoint.Administration Namespace

SPAutoSerializingObject

SPFeatureDefinition

SPPersistedObject

SPUrlZone

SPUserCodeAssemblyFileDefinition

SPUserCodeAssemblyGroupId

SPUserCodeCachedAssemblyGroup

SPUserCodeWrapper

Microsoft.SharePoint.Navigation Namespace

SPNavigation

SPNavigationNode

SPNavigationNodeCollection

SPQuickLaunchHeading

Microsoft.SharePoint.UserCode Namespace

SPProxyOperation

SPProxyOperationArgs

SPUserCodeExecutionContext

SPUserCodeValidationFailedException

SPUserCodeWorkflowContext

Microsoft.SharePoint.Utilities Namespace

AttachmentEnumerator

DateOptions

IconSize

ISPIdentifiableObject

ISPPerformanceMonitor

ISPScopedPerformanceMonitor

MoblogUtility

PermissionContext

PermissionMode

SPDateFormat

SPDiffUtility

SPEmailAttachment

SPEmailAttachmentCollection

SPEmailHeader

SPEmailHeaderCollection

SPEmailMessage

SPEncode

SPHttpUtility

SPMonitoredScope

SPPrincipalInfo

SPPrincipalSource

SPPrincipalType

SPRedirectFlags

SPStringUtility

SPUrlUtility

SPUtility

ThemeColor

ThemeFont

ThemeType

ThmxTheme

Microsoft.SharePoint.WebControls Namespace

SPControlMode

SPDataSourceMode

Microsoft.SharePoint.WebPartPages Namespace

BrowserBuilderType

DesignerBuilderType

FriendlyNameAttribute

HtmlDesignerAttribute

ManagedLinkAttribute

Permissions

SPAttachedProperty

SPWebCategoryNameAttribute

SPWebPartManager

Storage

WebPartPageUserException

WebPartZone

Microsoft.SharePoint.Workflow Namespace

ISPWorkflowEventReceiver

SPWorkflow

SPWorkflowActivationProperties

SPWorkflowAssignedToFilter

SPWorkflowAssociation

SPWorkflowAssociationCollection

SPWorkflowAssociationCollection.Configuration

SPWorkflowCollection

SPWorkflowEventCompletionType

SPWorkflowEventProperties

SPWorkflowEventReceiver

SPWorkflowExternalDataExchangeService

SPWorkflowExternalDataExchangeServiceCollection

SPWorkflowFilter

SPWorkflowManager

SPWorkflowModification

SPWorkflowModificationCollection

SPWorkflowPostponedEventType

SPWorkflowRunOptions

SPWorkflowState

SPWorkflowTask

SPWorkflowTaskCollection

SPWorkflowTaskProperties

SPWorkflowTemplate

SPWorkflowTemplateCollection

SPWorkflowWorkflowRoleCreator

Methods and Properties That Are Available with Restrictions

The following table lists methods that can be called from sandboxed solutions only if calling code conforms to certain restrictions on the parameters that are passed.

Method

Restriction

SPSite.SPSite(Guid)

The GUID that is passed to this constructor must be the ID of the current site collection.

SPSite.SPSite(String)

The URL that is passed to this constructor must resolve to the current site collection.

The following table lists properties that are read/write in farm solutions, but are read-only in sandboxed solutions.

SPSite.Owner

SPSite.PortalName

SPSite.PortalUrl

SPSite.SecondaryContact

SPUser.Email

SPWeb.AnonymousPermMask64

SPWeb.Author

SPWeb.Created

SPWeb.LastItemModifiedDate

See Also

Concepts

Restrictions on Sandboxed Solutions in SharePoint 2010

What Can Be Implemented in Sandboxed Solutions in SharePoint 2010

Other Resources

Sandboxed Solutions Resource Center | SharePoint 2010

SharePoint Developer Team Blog

SharePoint Developer Center