Pattern & Practices (1)

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

Farm Solutions

When use Full-Trust approach, deployed to GAC folder;
Whenuse bin/CAS, deployed to the bin folder in IIS. More limite. (no longe recommended)

Be careful:
The developer could fail to dispose of SPSite and SPWeb objects after use.
The developer could iterate through items in large lists instead of executing queries on the lists.
The developer could use for or foreach loops to aggregate data, instead of using SPSiteDataQuery or other recommended data aggregation methods.
The developer could use recursive method calls to iterate through information in every site within a site collection.
The developer could fail to close connections to external systems after use.
The developer could fail to trap timeouts when connecting to external systems.
The developer could overuse, or improperly use, session state.

SandBox Solutions

Not supporting Visual Web Part because it’s an ASCX file

Solution!! Use Visual Studio Powe Tool. The tool will generate and compile code representing the user control (.ascx) as part of the assembly. This avoids the file deployment issue.

If you attempt to use a SharePoint method that is not permitted in the sandbox environment, the method call will throw a MissingMethod exception. This occurs for all methods in the blocked namespacesThe Visual Studio 2010 SharePoint Power Tools has a Sandbox Compilation extension that generates build errors when the sandbox solution project uses types that are not permitted.

Within your sandboxed solutions, you can programmatically retrieve the SPUser object associated with the current request. However, you cannot access the underlying authentication token
for the current user.

Only allow these event receiver:

SPItemEventReceiver
SPListEventReceiver
SPWebEventReceiver

Can’t use feature event receiver in feature receiver class; you can do that declaratively.

How to tell you’re running tin Sandbox Mode?

if(System.AppDomain.CurrentDomain.FriendlyName.Contains(“Sandbox”)){
// Your code is running in the sandbox.
}

Two aproaches to work with external data:

1. BDC Model – external content type
2. SPList (actually comes from BDC ModeL) Won’t work if the back-end system uses non-integer identifier field; instead, use a full-trust proxy.

You can use sandbox solution to deploy declarative workflows (by SP Designer), which stored in content DB, and run with full trust.

Sandbox can’t deploy coded workflow.

A workflow activity is any class that derives from
System.Workflow.ComponentModel.Activity

——————————————————————————–
Solution Validation

create a class that inherits from the SPSolutionValidator abstract class. Two methods: ValidateSolution, ValidateAssembly.

If a sandbox worker process runs for more than 30 seconds, the user code service will terminate the process.

Logging functionality is unavailable
within the sandbox environment. Sandboxed solutions cannot write entries to the Windows Event log or the Unified Logging Service (ULS) trace log, nor can they create or retrieve diagnostic areas or categories.

Cannot read/write web.config; can use SPWeb.AllProperties, but no Property Bag.

Can’t deployed to file system; but can use a Module element with a Type attribute value of Ghostable or GhostableInLibrary
to deploy your templates. This indicates that the templates are deployed to the content database
instead of to the server file system.

——————————————————————————–
Hybrid – Sandbox + Full Trust Proxy

Sandbox can consume:
(1) Full Trust Proxy – from SPProxyOperation (GAC)
(2) External ontext Type
(3) Custom Workflow Activities

The SharePoint context (SPContext) is not available within the proxy operation class.

3 key components behind full trust proxies:
SPProxyOperation – include method: Execute()
SPProxyOperationArgs — Parameters
SPUtility.ExecuteRegisteredProxyOperation —

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: