Thursday, July 16, 2015

Exception Handling in Client Object Model

The CSOM provides a class named "ExceptionHandlingScope" that is specifically defined to support such situations and avoid executing multiple queries against the server .


ClientContext ctx = new ClientContext("http://SP2013.local/");

ExceptionHandlingScope scope = new ExceptionHandlingScope(ctx);

using (scope.StartScope()) {

using (scope.StartTry()) {

// Try to do something on the server side
}
using (scope.StartCatch()) {

// Do something else in case of failure on the server side
}
using (scope.StartFinally()) {

// Execute this code, whatever is the result of previous code blocks
}
}

ctx.ExecuteQuery();

The server will begin executing the code inside the StartTry block, and then in case of failure,

it will execute the code in the StartCatch block. if there is any  exceptions occur in the

StartTry block, the server will finally execute the code in the StartFinally block.

Wednesday, July 15, 2015

Difference between Farm Solutions and Sandbox solutions

Farm Solutions:
Farm Solutions are hosted in the IIS worker process (W3WP.exe), run code that can affect the whole Farm.
Farm Solutions are deployed by Farm Administrators.When you debug a SharePoint project whose Sandbox Solution is set to false.

Sandbox Solutions:
Sandbox Solutions are hosted in SharePoint  usercode solution worker process(SPUC Worker process)
Sandbox solutions are deployed by Site collection administrator.If you run  code that can affect the site collection of the solution.
Sandbox solutions are secure monitored process.
Sandbox solutions can be deployed without requiring  SharePoint Administrator access.

Sandbox solutions supports following  items

  • List Definition
  • List Instance 
  • Content Types
  • Event Receivers
  • Navigation 
  • SPItem Event Receiver
  • SP List Event Receiver
  • SP Web Event Receiver


Limitations:


  • Mapped folders cannot be  added to  the project .
  • Microsoft.SharePoint.office.server can not be used in Sandbox solutions.
  • SPUtilities.SendMal  is not allowed  in Sandbox solutions