Sometimes, when rendering the web part, I get the error:
[SPUserCodeExecutionPipelineFailedException: Sandboxed code execution request failed.]
It's not a nice error but it only appears sometimes. I'm running on a four-server farm so I assumed it was something to do with the sandboxed code service not running on one of the servers. However, the service was running on all of them.
It's probably not solved anything (but it's a development environment so I'm not too bothered), but I found a workaround:
- Go to Central Administration
- Click on System Settings, and then Manage user solutions
- In this screen, select "All sandboxed code runs on the same machine as a request".
- Click OK.
The webpart now works reliably. I'm assuming one of my servers isn't happy with the sandbox service credentials but I can move on with my life for now.