I recently had to add a WebPart to a Sandboxed Solution for one of our upcoming Products. Basically, adding a WebPart to a Sandboxed Solution is straight-forward, however for Sandboxed Solutions some other tasks are required. Often, this results in an Error that stating “Failed to load Assembly. The System can’t find the Assembly or one of its dependencies”.
This occurs because in Sandboxed Solutions – which are necessary for SharePoint Online or Office 365 – requires some additional things to do. Once you figured that out, adding a WebPart is very easy.
Adding a WebPart automatically is done by adding it to a Module (in the Elements-Section)
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="WordDocumentGeneration">
Within the Module-Element, simply add the WebPart as you would normally do:
<AllUsersWebPart ID="TeslaId" WebPartZoneID="Left" WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="CodeForce.DocumentGeneration.OnlineServices.DocumentGeneratorConfiguration.TeslaConfiguration.TeslaConfiguration, CodeForce.DocumentGeneration.OnlineServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=07f7c9e97535f1e6" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
<Solution SolutionId="4c51dd16-8df7-4baa-abc0-c56758c95ccb" xmlns="http://schemas.microsoft.com/sharepoint/" />
</metaData>
<data>
<properties>
<property name="Title" type="string">Easy Document Generation for SharePoint</property>
<property name="ChromeType" type="chrometype">None</property>
<property name="Description" type="string">Generates Word Documents from List Data in SharePoint.</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</AllUsersWebPart>
An important step is to add the “Solution” Tag. This tells the Sandboxed Solution User Code Service with Microsoft SharePoint where the WebPart can be found. You can find the GUID for the Solution ID in the Package / Manifest:
- sharepoint module xml manifest
Have fun with SharePoint Sandboxed Solutions!

