SharePoint 2010: Sandboxed Code Service is failing to start


Symptoms


Consider the following scenario:

You attempt to start the Sandboxed code service within SharePoint 2010.  The processes associated with the service will appear to come up to the user but will disappear immediately. The SharePoint ULS logs show the following error:

'Process perf counters are disabled. Sandboxed code monitoring cannot continue.'

Cause


This issue occurs when the registry key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance\Disable Performance Counters' value is set to 1.

Resolution


To fix this issue, you will have to modify the registry. 

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

322756 - How to back up and restore the registry in Windows

To fix the issue and run sandboxed code service successfully, the user should delete the registry key or set the value to '0'. To do this, follow these steps:

  1. Click Start, type regedit in the Start Search box, and then press ENTER.
  2. Locate and then click the following registry sub key:
         HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance\Disable Performance Counters
  3. On the Edit menu, click Modify
  4. In the Value data box, change the value to '0' and click on OK.
  5. Exit Registry Editor.

More Information


Within the SharePoint ULS logs, you may see the following errors:

SPUCHostService.exe (0x17C0)   0x172C SharePoint Foundation  Sandboxed Code Service  ei19 Verbose
- An unhandled exception was caught while trying to initialize the SPUserCodeHostService. This service will now terminate.
PID = 6080. Exception = System.ComponentModel.Win32Exception: Unknown error (0xc0000bbc)     at Microsoft.SharePoint.Win32.SPPdh.CheckReturnValue(PDH_STATUS status, Boolean throwOnError)     at Microsoft.SharePoint.Utilities.SPPerformanceCounter.NextValue(Int32 retry, Int32 retryInterval)     at Microsoft.SharePoint.UserCode.SPUserCodePerformanceCounterHelper..ctor(String processName, Int32 processInstanceId)     at Microsoft.SharePoint.UserCode.SPUserCodeProcessMonitor.EnsurePerfCounters(IMonitorableProcess monitorableProcess, Int32& indexShimInstance, Int32& indexProxyInstance)     at Microsoft.SharePoint.UserCode.SPUserCodeProcessMonitor.CreateMonitoredProcess(IMonitorableProcess monitorableProcess)     at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessPool.AddProcess(ISPUserCodePoolableProcess process)     at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessPool.StartProcessInternal()     at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessPool.StartProcess()     at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessPool.Initialize(String instance)     at Microsoft.SharePoint.UserCode.SPUserCodeExecutionHost.InitializeInternal(ISPUserCodePoolableProcessFactory processFactory)     at Microsoft.SharePoint.UserCode.SPUserCodeExecutionHostService.InitializeThreadProc(Object stateInfo)

SPUCHostService.exe (0x099C)  0x0A1C SharePoint Foundation   General  84yj Medium 
Performance Counter OS (pdh) call failed with error code PDH_INVALID_HANDLE.

SPUCHostService.exe (0x099C)  0x0A1C SharePoint Foundation  User Code Service  ela0 Verbose
- Reading perf counter IO Data Bytes/sec failed with exception System.ComponentModel.Win32Exception: Unknown error (0xc0000bbc)     at Microsoft.SharePoint.Win32.SPPdh.CheckReturnValue(PDH_STATUS status, Boolean throwOnError)     at Microsoft.SharePoint.Utilities.SPPerformanceCounter.NextValue(Int32 retry, Int32 retryInterval)     at Microsoft.SharePoint.UserCode.PerfCounterData.Update(), reusing last value 0.

SPUCHostService.exe (0x099C)  0x0A1C SharePoint Foundation  User Code Service  ei0r Verbose
- Monitoring read perf counters for process "SPUCWorkerProcess": PercentProcessorTime=0 ProcessVirtualBytes=0 ProcessHandleCount=0 ProcessThreadCount=0 ProcessIOBytes=0

SPUCHostService.exe (0x099C)   0x0A1C SharePoint Foundation  General   84yj Medium
Performance Counter OS (pdh) call failed with error code PDH_INVALID_HANDLE.

SPUCHostService.exe (0x099C)  0x0A1C SharePoint Foundation  User Code Service  ela0 Verbose
- Reading perf counter Thread Count failed with exception System.ComponentModel.Win32Exception: Unknown error (0xc0000bbc)     at Microsoft.SharePoint.Win32.SPPdh.CheckReturnValue(PDH_STATUS status, Boolean throwOnError)     at Microsoft.SharePoint.Utilities.SPPerformanceCounter.NextValue(Int32 retry, Int32 retryInterval)     at Microsoft.SharePoint.UserCode.PerfCounterData.Update(), reusing last value 0.