Sandbox Development – Reference the User Code DLL

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…

  1. 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.)
  2. 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!

Advertisement
Sandbox Development – Reference the User Code DLL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.