SharePoint 2010 and SharePoint Online (Office 365) allow for custom development in the form of Sandbox Solutions. Your code is restricted to a subset of the SharePoint API but allows you do most regular operations inside a Site Collection.
Problem
Here’s a scenario that fails every time and everywhere:
- Create a sandboxed Event Receiver that is registered to ItemUpdating
- Create a sandboxed Web Part that does an SPListItem.Update() from the SharePoint Object Model
- Watch how the sandbox errors out with the following message
[SPUserCodeSolutionExecutionFailedException: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request.]
- Now just edit the item from the SharePoint UI and watch how that works wonderfully well
Sandbox Request Architecture
So what’s going on here ?

In light of this you might conclude that there’s no possible communication between two sandbox code requests (the Web Part and the Event Receiver). As good an explanation as any, so feel free to chime in.
Other things
Here are some other things I stumbled upon while researching this issue:
- ItemUpdated is not affected and works fine
- You cannot make your “after” events Synchronous in a Sandbox as they won’t fire
- (Sandbox) Event Receivers can only be registered declaratively in the Feature XML
- The certificate checking issue (crl.microsoft.com) has the same error message, but is unrelated to this issue
- Triggering the update from non-Sandbox code works fine
Workaround
So how about we conclude with a workaround ?
In some cases you could use the “after” Event Receiver rather than the “before” Event Receiver, but isn’t really a sound solution.
The best option would be to rewrite the Web Part to run its code on the client, either through Client OM (ECMAScript or Silverlight), or the SharePoint Web Services.

http://msdn.microsoft.com/en-us/library/ff798452.aspx
Property Bag
SPWeb exposes two ways of interacting with the property bag:
- SPWeb.Properties exposes a Microsoft.SharePoint.Utilities.SPPropertyBag
- SPWeb.AllProperties exposes a System.Collections.Hashtable
The former is considered legacy, also it stores the Key value as lowercase, while the latter keeps the casing of Key and Value intact.
Here’s a code sample:
1 string url = "http://intranet";
2
3 using (SPSite site = new SPSite(url))
4 {
5 SPWeb w = site.OpenWeb();
6 w.AllProperties.Add("First Key", "First Value");
7 w.Update();
8
9 SPPropertyBag p = w.Properties;
10 p.Add("Second Key", "Second Value");
11 p.Update();
12 }
You can see the properties for a web using SharePoint Designer:
SharePoint 2007:
SharePoint 2010:

Case matters
When you configure a Search Center in the Site Collection Settings, a property named “SRCH_ENH_FTR_URL” stores the location to the Search Center. If this property isn’t entirely uppercase, it won’t be picked up correctly.
Sandbox Solutions
So what about Sandbox Solutions in SharePoint 2010 ?
- SPWeb.AllProperties can only be read from. Updating it doesn’t throw any exceptions but has no effects either.
- SPWeb.Properties cannot be used and throws a TypeLoadException:
