I have created a custom web part which presents a form to create a SharePoint site below the current site, while performing some ancillary actions like updating a list of subsites on the front page to include the newly created subsite.

Development has, as per Microsoft guidelines, been performed on a SharePoint Foundation box which closely resembles the environment in Microsoft Online. Deployment and testing on this test machine is obviously as a sandboxed solution. Before adding the web part to the SharePoint Online gallery, I put a generic try-catch around all my code to be able to pick up any error messages in the production environment, where no debugger is available.

The web part does indeed work (the subsite is created), but at some undeterminable point after this, execution stops with "Web Part Error: Sandboxed Code Execution Request Failed". This is a generic error message which circumvents my try-catch. Presumably, I am doing something that the Sandboxed Code Service doesn't like. But the code works fine in the sandboxed server environment.

Is there any way to get a more specific error message? Does anyone have experience developing sandboxed solutions for SharePoint Online and know if there are any less painful practices? I guess I could do a "manual search" and comment out each individual line of code where my error could be, but this is a ridiculously painful approach.

有帮助吗?

解决方案 3

Visual Studio SharePoint Power Tools apparently extends Visual Studio to show an error when you are trying to use types or members in a sandboxed project which are not allowed. This should stop you from stepping in any major pitfalls. VSPT also lets you develop Visual Web Parts for the sandboxed code service, which makes developer life a bit easier.

其他提示

Maybe you could use this to debug? It pops up an alert message with the error in it. (I didn't test this) After removing the bug I would delete this again...

string MyScript = @"<script language='javascript'>alert({0});</script>";
try
{
   //Your code
}
catch (Exception ex)
{
   if (!Page.IsClientScriptBlockRegistered("DebugScript"))
   {
     MyScript = String.Format(MyScript, ex.ToString());
     Page.RegisterClientScriptBlock("DebugScript", MyScript);
   }
}

I can't remember if its possible or not, but can you enable the Developer Dashboard in SharePoint Online? If so, would that provide you with any additional information that may be useful? (Sorry, I'm not a dev so I'm not completely up to speed on the tool)

许可以下: CC-BY-SA归因
scroll top