While building a SharePoint 2010 demo environment on Windows 7 I ran into an issue with the SharePoint 2010 User Code Host service not starting.
The User Code Host service is a new service in SharePoint 2010 that enables the sandbox solutions feature. You can read more about sandbox solutions here.
My first step in identifying the issue was to review the system and application event logs on Windows 7. Neither of these logs provided any clues as to the cause of the service failure. I could see that the service did report back a successful start but then it almost immediately reported a failure and then stopped.
To dig deeper into the issue I used ULSViewer to view the SharePoint 2010 logs in real-time while using the Windows 7 service manager to manually start the User Code Host service. I could see in the logs that the User Code Host service loaded and registered several configuration and reference files. The last two lines written to the log during the attempted service start showed:
02/22/2011 13:17:36.13 SPUCHostService.exe (0x0620) 0x22D8 SharePoint Foundation Sandboxed Code Service fe7l Medium - – Value cannot be null. Parameter name: ip – SPUserCodeExecutionHost.Initialize failed to open channel on port: 32846
02/22/2011 13:17:36.14 SPUCHostService.exe (0x0620) 0x22D8 SharePoint Foundation Unified Logging Service 8wsw High Now terminating ULS (SPUCHostService.exe, onetnative.dll)
As you see, there was an error during the initialization of the service related to configuring either a listening or sending channel on port 32846. My first reaction was to verify that the Windows 7 firewall was not blocking that specific port. A quick review showed that the SharePoint installation had setup an incoming firewall rule, so that couldn’t be the problem.
This specific Windows 7 computer is joined to a domain and also has both wired and wireless network adapters. To rule out the issue with multiple network adapters I decided to disable the wireless network and only operate on a wired network. This time while manually starting the User Code Host service I saw the following error logged:
02/22/2011 13:14:34.08 SPUCHostService.exe (0x1CE8) 0x25AC SharePoint Foundation Sandboxed Code Service fe7l Medium - – No such host is known – SPUserCodeExecutionHost.Initialize failed to open channel on port: 32846
This error had me thinking that maybe the issue has nothing to do with multiple adapters or firewalls but instead is a name resolution issue. My computer name is DEMOA but the fully qualified domain name is DEMOA.MYDOMAIN.COM. Could it be that SharePoint is trying to use my computer name which isn’t being properly resolved by DNS?
I opened up the HOSTS file located at c:windowssystem32driversetc and added an entry for DEMOA with an IP address of 127.0.0.1. I enabled all of my network adapters again and proceeded to manually start the User Code Host service. SUCCESS! This time the service completed the initialization process and continued to run as it should.
I validated that the issue was resolved by creating a test sandbox solution using Visual Studio 2010. A quick build and deploy proved that the service was working properly.