Saturday, November 27, 2010

Deploy WebPart Page with Custom Web Part into SharePoint 2010 Sandbox


I recently ran into an issue with deploying a custom web part in the SharePoint 2010 Sandbox. What I had done was create a custom web part that worked just fine in the SharePoint 2010 Sandbox.

The next thing I wanted to do was provide a web part page as part of my solution package with the custom web part added to the web part page. This way when the deployment is complete, there is a page ready to go with the web part and no one needs to do a manual step of creating the web part page and configuring the web part.

Provisioning the web part page was no problem, however when I had configured the page with the custom web part I received the following errors which were no very helpful.

SharePoint Foundation Web Parts 8l4f Monitorable Error importing WebPart. Assembly MyAnonymousComments, Version=, Culture=neutral, PublicKeyToken=dce01f6d2636f2c1, TypeName. MyAnonymousComments.SubmitAnonymousComment.SubmitAnonymousComment, MyAnonymousComments, Version=, Culture=neutral, PublicKeyToken=dce01f6d2636f2c1 6a9ded04-b7dc-42df-8f5a-af6037857a8b

SharePoint Foundation Web Parts 7935 Information http://win-osd73bv7a62/sites/AnonymousCommentPages/AnonymousCommentsLanding.aspx - An unexpected error has been encountered in this Web Part. Error: Cannot import this Web Part., DesignText: <webParts> <webPart xmlns=""> <metaData> <type name="MyAnonymousComments.SubmitAnonymousComment.SubmitAnonymousComment, MyAnonymousComments, Version=, Culture=neutral, PublicKeyToken=dce01f6d2636f2c1" /> <importErrorMessage>Cannot import this Web Part.</importErrorMessage> </metaData> <data> <properties> <property name="Title" type="string">Submit Anonymous Comment</property> <property name="Description" type="strin... 6a9ded04-b7dc-42df-8f5a-af6037857a8b

SharePoint Foundation Web Parts 7935 Information ...g">Web part that will submit anonymous comments into a list.</property> </properties> </data> </webPart> </webParts>, SourcePreamble: DWP 6a9ded04-b7dc-42df-8f5a-af6037857a8b

SharePoint Foundation E-Mail 6871 Information The Incoming E-Mail service has completed a batch. The elapsed time was 00:00:00. The service processed 0 message(s) in total. 07e8b8a8-b763-4ad3-8836-ecd457f50303


The resolution was that I needed to add a solution tag like the one below. I did not need this Solution element when configuring other out of the box SharePoint web parts, but when it comes to custom web parts that are deployed into the SharePoint 2010 Sandbox this is needed. I assume it because the DLL where the part is located is not in the GAC or the bin, so the Sandbox runtime needs to know where the DLL is located. The GUID for the solution package tells it where it is located.

      <AllUsersWebPart WebPartZoneID="Left" WebPartOrder="1">
<webPart xmlns="">
<type name="MyAnonymousComments.MostRecentResponsesWebPart.MostRecentResponsesWebPart, MyAnonymousComments, Version=, Culture=neutral, PublicKeyToken=dce01f6d2636f2c1" />
<Solution SolutionId="0a30dc69-b582-4a69-97d2-99862248c74e" xmlns="" />
<property name="Title" type="string">Most Recent Responses</property>
<property name="Description" type="string">Will retrieve the most recent anonymous responses.</property>
<property name="ListName" type="string">Anonymous</property>


This link pointed me in the right direction -

No comments: