Friday, 4 June 2010
Deployment Error on Sandbox Solution while deploying web part
Error occurred in deployment step 'Activate Features': Timeout occurred while running the SharePoint Sandboxed Code service. This service is required to run sandboxed solutions in SharePoint. Please ensure the service is configured correctly in SharePoint
Solution
Goto Services and start "Sharepoint 2010 User Code Host" Service
Wednesday, 2 June 2010
Calling a Web Service in Sandbox Solution
In order to call a web service in sandbox environment following steps should be followed.
Note: Assuming you already have created the web service and deployed it in IIS
1. Create a class library project and which is derived from “SPProxyOperation” (Microsoft.SharePoint.UserCode namespace).
Code Snippet
class ProxyProvider : SPProxyOperation{
if (args != null)
{
ProviderSoapClient client = new ProviderSoapClient();
ProviderArgs providerArgs = args as ProviderArgs;
return client.GetDepartmentByCode(providerArgs.DeptCode);
}
else
{
return "Error while calling Web Service...";
}
}
}
2. Create another class which should be used for passing arguments to the SPProxyOperation class
{
public int DeptCode
{
get;
set;
}
public ProviderArgs(int code)
{
this.DeptCode = code;
}
}
4. Implement Execute method of SPProxyOperation class.
5. Attach below attribute with the assembly
[assembly:System.Security.AllowPartiallyTrustedCallersAttribute()]
6. Make sure assembly is strongly named.
7. Deploy the assembly in GAC using GACUTIL(Since drag and drop assembly gives access denied error).
8. Register the assembly in Sharepoint
To register a assembly in Sharepoint “Power Shell” can be used.
Write below scripts in a .ps1 file and run from power shell
Param($assemblyName, $typeName)
$userCodeService = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
$proxyOperationType = new-object -typename Microsoft.SharePoint.UserCode.SPProxyOperationType -argumentlist $assemblyName, $typeName
$userCodeService.ProxyOperationTypes.Add($proxyOperationType)
$userCodeService.Update()
9. Since this is full trust proxy class so it would run under “SPUCWorkerProcessProxy.exe” so add the web service related configuration setting in SPUCWorkerProcessProxy.exe.config file which can be found under “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\UserCode” folder.
10. Now you are ready to call the web service method via Proxy operation class. Use below method to call the web service from your Sandbox Solution.
SPUtility.ExecuteRegisteredProxyOperation("AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fffdd72d4537ce50", "NameSpace.ClassName", new ArgumentClass(Argument));
Query List/Document Library in Specific Folder
To query SharePoint List or Document Library in specific Folder “ FolderServerRelativeUrl ” as part of the CAML Query Code Snippet ...
-
#Add a sharepoint group using power shell #Create a sharepoint custom permission using Power shell $web = get-SPWeb "http://sitecollect...
-
I am very sure that most of the Sharepoint developers must have used _spBodyOnLoadFunctionNames to inject javascript methods on the sharepo...
-
This issue occurs when you do backup restore of the site/site collection. Due to this you can not see the page in design mode due to some re...