How to register your full-trust proxy with SharePoint 2010

Posted on 12/7/2009 @ 3:11 AM in #SharePoint 2010 | 0 comments | 1432 views

I will eventually link this blogpost to a series of blogposts on Sandbox solutions, but for now, Here is a tiny little powershell script that will allow you to register a full-trust proxy that you can then use with sandbox solutions in SharePoint 2010. Put this in a file called “RegisterProxy.ps1”.

   1: Param($assemblyName, $typeName)
   2: $userCodeService = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
   3: $proxyOperationType = new-object -typename Microsoft.SharePoint.UserCode.SPProxyOperationType -argumentlist $assemblyName, $typeName
   4: $userCodeService.ProxyOperationTypes.Add($proxyOperationType)
   5: $userCodeService.Update()

The usage is hella simple -

From powershell, run the following command -

   1: .\RegisterProxy.ps1 -assemblyName "SandBoxWebPartWithProxy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=64b818b3ff69ccfa" -typeName "SandBoxWebPartWithProxy.ProxyCode.FileCreateOperation"

You can also easily verify if the proxy got registered or not! by running the below -

   1: [Microsoft.SharePoint.Administration.SPUserCodeService]::Local.ProxyOperationTypes

Please post your comments:


Your feedback will be submitted for moderation, and will appear after it is approved.

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box: