There is often a combination of limits that prevent publishing forms in the sandbox. While only 10% of the publishing time may be related to the code, the time required to process the views contained in the xsn contribute to the overall overhead. So forms with more views may see this problem with a minimal amount of code. The only way to work around this is to reduce the number of views, or increase the sandbox limits.
Below is one script to increase the values, the second to restore
back to default levels after publishing. The “SharePoint 2010 User Code Host”service needs to be restarted after running the script. The script only needs to be run once, but the "SharePoint 2010 User Code Host" service must be restarted on all servers in the farm where the service is running.
This numbers are probably overkill, but we
went over what we expected it to need to successfully publish
#
#
THESE LIMITS SHOULD ALLOW TO PUBLISH YOUR FORM
#
$spCodeService
= [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
$cpu
= $spCodeService.ResourceMeasures["CPUExecutionTime"]
#
NOTE THE VALUE BEFORE THE UPDATE TO RESET LATER
$cpu.AbsoluteLimit
$cpu.AbsoluteLimit
= 600
$cpu.Update()
$cycles
= $spCodeService.ResourceMeasures["ProcessCPUCycles"]
#
NOTE THE VALUE BEFORE THE UPDATE TO RESET LATER
$cycles.AbsoluteLimit
$cycles.AbsoluteLimit
= 2000000000000
$cycles.Update()
#
NOTE THE VALUE BEFORE THE UPDATE TO RESET LATER
$spCodeService.WorkerProcessExecutionTimeout
$spCodeService.WorkerProcessExecutionTimeout
= 600
$spCodeService.Update()
#
#
"SharePoint 2010 User Code Host" must be restarted in the services
applet
#
After publishing, run this script
#
#
RESET LIMITS TO DESIRED DEFAULTS
#
$spCodeService
= [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
$cpu
= $spCodeService.ResourceMeasures["CPUExecutionTime"]
#
RESET CPUExecutionTime to normal running level (60 is SharePoint default)
$cpu.AbsoluteLimit
= 60
$cpu.Update()
$cycles
= $spCodeService.ResourceMeasures["ProcessCPUCycles"]
#
RESET ProcessCPUCycles to normal running level (100000000000 is SharePoint default)
$cycles.AbsoluteLimit
= 100000000000
$cycles.Update()
#
RESET WorkerProcessExecutionTimeout to normal running level (30 is SharePoint
default)
$spCodeService.WorkerProcessExecutionTimeout
= 30
$spCodeService.Update()
#
#
"SharePoint 2010 User Code Host" must be restarted in the services
applet
#