Farm solution VS Sandbox solution
There are some differences between Farm Solution and Sandbox solution as follows -Farm Solutions:
- Farm solutions are hosted in the IIS worker process (W3WP.exe).- If you run any code in farm solution the whole farm will got affected.
- If you deploy any feature or retract any feature the whole application pool got recycled.
- Since they are scoped as farm level, they have full trust access to all the resources.
- When the Sandboxed Solution property is set to False, selecting Build\Deploy will deploy the solution to the Farm Solution Gallery.
Sandbox solution:
- Sandboxed solutions are hosted in the SharePoint user code solution worker process (SPUCWorkerProcess.exe).
- The process runs under a CAS policy that restricts programmatic access to any resource outside the sandbox.
- Never restart the IIS application pool.
- If you run any code it will affect only the site collection of the solution.
- Helpful if you have shared hosting. - When the Sandboxed Solution property is set to True, selecting Build\Deploy Solution deploys the solution to the site collection Solution Gallery.
Sandboxed solutions, which are hosted in the SharePoint user code solution , worker process (SPUCWorkerProcess.exe) run code that can only affect the site collection of the solution.- The process runs under a CAS policy that restricts programmatic access to any resource outside the sandbox.
- Never restart the IIS application pool.
- If you run any code it will affect only the site collection of the solution.
- Helpful if you have shared hosting. - When the Sandboxed Solution property is set to True, selecting Build\Deploy Solution deploys the solution to the site collection Solution Gallery.
Because sandboxed solutions do not run in the IIS worker process, neither the IIS application pool nor the IIS server must restart.
Visual Studio attaches the debugger to the SPUCWorkerProcess process that the SPUserCodeV4 service in SharePoint automatically triggers and controls. It is not necessary for the SPUCWorkerProcess process to recycle to load the latest version of the solution.
Disadvantages of Sandbox solutions:
1. No support to Microsoft.SharePoint.WebPartPages namespace.
2. It’s more secure, can’t elevate privileges and leads to more complex codes.
3. Making web service calls over the internet, or accessing code that is not marked to allow partially trusted callers are not supported. You also can’t deploy files to disk or add assemblies to the GAC in a sandboxed solution, and security-related functionality, such as running RunWithElevatedPriviledges and other SPSecurity methods, is not allowed.
4. No support to SPUtility.SendEmail namespace for sending mails.
Disadvantages of Sandbox solutions:
1. No support to Microsoft.SharePoint.WebPartPages namespace.
2. It’s more secure, can’t elevate privileges and leads to more complex codes.
3. Making web service calls over the internet, or accessing code that is not marked to allow partially trusted callers are not supported. You also can’t deploy files to disk or add assemblies to the GAC in a sandboxed solution, and security-related functionality, such as running RunWithElevatedPriviledges and other SPSecurity methods, is not allowed.
4. No support to SPUtility.SendEmail namespace for sending mails.