Tip #70: How to compile sandboxed solutions against the restricted API

As you know SharePoint 2010 provides you "sandboxed solutions" to run your code in the restricted environment (for testing or other purposes) that doesn't affect the production farm functionality.

Such functionality is achieved that your solution is compiled against the subset of Microsoft.SharePoint namespace, and Visual Studio will trim intellisense of available method. However the compilation happening against the full Microsoft.SharePoint.dll

The recommendation for the custom developed sandboxes solutions is to replace Microsoft.SharePoint.dll reference on [SharePoint Root]\UserCode\assemblies\Microsoft.SharePoint.dll to be sure that you code compiles and doesn't use restricted API.