Remarkably, I’ve only just started doing my first Sandboxed development in SharePoint 2010. (Most of our customers own their own servers, and want functionality you can’t easily build in the Sandbox alone).
Anyway, I knew that the API you could use in the sandbox was smaller than the full API, and I wanted my solution to warn me (e.g. fail to compile) if I tried to use something that wasn’t available in the sandbox. I found two approaches…
- Replace the reference to Microsoft.SharePoint.dll. If you instead reference the version for the sandbox ( in
14/UserCode/assemblies
) and the project compiles successfully then it is a valid sandbox solution.(Note: Only reference this dll for validation during development. You should reference the Mirosoft.Sharepoint.dll at/14/ISAPI
for Release, although I’m not entirely sure why.) - Use the SharePoint Power Tools Visual Studio Extension. Not only does it give a Sandboxed Visual Web Part project (nice!), but it also changes Intellisense and compilation to use the Sandboxed API. Fantastic!
Really, the Visual Studio extension is much simpler than changing and restoring assembly references, so I would always recommend it!