Thursday, 5 May 2011

WebControls not supported in sandbox solutions

Problem:  I wanted to use a SPGridView in a sandbox solution, so I added the code an intellesense doesn't pick it up.  Looked up the SPGridView class documentation on MSDN and it's not supported.  Not really sure why but hardly anything in the Microsoft.SharePoint.WebControls assembly works with sandbox solutions.

Initial Hypothesis:
Microsoft.SharePoint.WebPartPages.ListViewWebPart is another example of a control that can't be added progratically, however it can be added using SharePoint Designer.  I'm baffled!


Maks Mulawa said...

Hi Paul,

Microsoft.SharePoint.WebControls namespace is part of Microsoft.SharePoint.dll which public members has been seriously stripped-down. Microsoft.SharePoint.dll shim assembly doesn't almost any of the members of WebControls namespace.

I would suspect that MS didn't want to rewrite their controls for the Sandbox environment, as the priority for them is to keep it backward compatible.

You can still add them to the page through the SharePoint designer, as these webparts are not executed on the User Code Service (Sandbox), but in w3wp.exe.

Post a Comment