SharePoint 2010 : Sandbox Solution Part 4 Full Trust Proxy

Full Trust Proxy:  Sandboxed solution to execute an action that is ordinarily not available to sandboxed solutions.

One of these techniques is to create a special kind of operation that runs in a full trust process, but that can be called from a sandboxed solution. The operation is deployed as a farm solution by a farm administrator who trusts it and is prepared to let sandboxed solutions call it. These operations are called full-trust proxy operations. (Microsoft Definition).



Other words:
  1. Full trust proxy is a farm solution that runs Outside the Sandbox Solution. 
  2. Sandbox Solution uses that assembly and call Execute method to perform the operation which was out the scope of sandbox solution. The class inherits from SPProxyOperation
  3. Full trust Proxy Input parameters used as serialize class (used “Serializable” attribute) that inherits from SPProxyOperationArgs 
  4. Register proxy with User Code Service during Feature activation. 
  5. Referenced the assembly in Sandbox solution use it.
Steps :
  1. Create an Empty SharePoint Farm Solution let’s Call it "AddlinkdemoProxy". Go to properties AssemblyInfo.cs file Add new attribute [assembly: AllowPartiallyTrustedCallers()]
  2. Add new Class file name it CustomAddLinkProxy.cs. Make it public and inherits SPProxyOperation. Override Execute Method it takes SPProxyOperationArgs as argument. For passing SPProxyOperationArgs we need to create a class with Serializable attribute. Create the class parameters that will be used in Sandbox Solution.
  3. Add Code in feature activation to register our custom feature activity.
  4. Add new project and set as sandbox solution and proxy assembly to that project and use this proxy in sandbox to run the farm code.
Download the full code.


Popular posts from this blog

SharePoint RPC Protocols Examples Using OWSSVR.DLL

STS CryptographicException Error : Key set does not exist

SharePoint 2016 JavaScript framework