Let’s start from beginning:
- You build sandbox solution that consist of branding feature will provision masterpages to masterpage gallery and styles to style library. Easy
- You are deploying solution to the site. You activating solution, all fine, branding feature has been activated automatically.
- Some time later you are upgrading a solution because you fixed few issues.
- You are deactivating solution, uploading solution, then you click activate. You get: Exception from HRESULT: 0x81070966
- Solution seems to be activated even you got this nasty error.
- You go to site collection features and you realize that your branding feature is not activated.
- You try to activate it and you get: Unhandled exception was thrown by the sandboxed code wrapper’s Execute method in the partial trust app domain: An unexpected error has occurred.
- No errors in trace log
When this happens to you, check if your masterpage has not been checked out by someone else. That was true in my case, someone else was provisioning this package and because sandbox files are always checked out to the person deploying it, if one does not remember to publish them manually of through the script, you can get this nasty error.