Playing in SharePoint 2010’s sandbox

 

As the SharePoint developers among us are probably aware, the newest version of SharePoint now has the sandbox mode for solutions.  I knew about this mode and that it put certain limitations on the code in a sandboxed project.  What I did not realize, was that in a sandboxed solution you cannot create connectable web parts nor can you call external services.  Well you can create connectable web parts and call external services but if you do you should expect them to fail.

I recently was on a project where I the client needed a connected web part that hosted a Silverlight Bing maps control.  This control would display the items that were sent in using the web part connection.  This enabled the client to connect the web part to a list view web part and as the list view was filtered, so were the items in the silver light Bing map.  The other requirement was that they wanted this web part to be in the new Sandbox solution.  Sounds pretty simple right?

Well the Silverlight map part was pretty easy after i came up with a way to pass in the connected data.  Even the connected web part was pretty easy.  There is nothing special there, I just followed the MSDN example and that worked like a charm. 

Then came a problem.  I changed the SharePoint project from un-sandboxed to sandboxed.  After that my web part would no longer accept connections.  There was no error or information message as to why this was the case.  The connections context menu was just grayed out and a tool tip message just informed me that the web part did not accept connections.  The web part also performed an initial geocode using the Bing geocoding service and that stopped working.  I would get a error when the web part tried to geocode with a somewhat cryptic error.  This error had to do with the code attempting to run the program csc.exe.  I couldn’t figure out why my web part was trying to call the compiler. 

So the moral of the story is, if you need to call external services or have connectable web parts don’t try to use a sandboxed solution.

var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));

try{
var pageTracker = _gat._getTracker(“UA-20994872-2”);
pageTracker._trackPageview();
} catch(err) {}

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s