Cannot recognize the XML namespace of this Web Part


In my earlier post Provisioning webparts through feature, we saw how can custom or out of the box web parts be provisioned on a page through visual studio feature.

Note that sometimes using this approach you might stumble on this error “Cannot recognize the XML namespace”

Notice that when ou download the configured web part you would see 2 kinds of namspaces. http://schemas.microsoft.com/WebPart/v2 and http://schemas.microsoft.com/WebPart/v3.  In SharePoint you have two types of webparts, v2 and v3. Both have slightly different syntax

The elements.xml file for v2 would look something like below

    <File Path="Pages\AccessDenied.aspx" Url="AccessDenied.aspx" Type="GhostableInLibrary" ReplaceContent="TRUE" >
      <AllUsersWebPart WebPartZoneID="MainZone" ID="MeetingSearchWebPart" WebPartOrder="1">
        <![CDATA[
     <WebPart xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>Access Denied</Title>
  <FrameType>Default</FrameType>
  <Description>Allows authors to enter rich text content.</Description>
  <IsIncluded>true</IsIncluded>
  <ZoneID>MainZone</ZoneID>
  <PartOrder>0</PartOrder>
  <FrameState>Normal</FrameState>
  <Height />
  <Width />
  <AllowRemove>true</AllowRemove>
  <AllowZoneChange>true</AllowZoneChange>
  <AllowMinimize>true</AllowMinimize>
  <AllowConnect>true</AllowConnect>
  <AllowEdit>true</AllowEdit>
  <AllowHide>true</AllowHide>
  <IsVisible>true</IsVisible>
  <DetailLink />
  <HelpLink />
  <HelpMode>Modeless</HelpMode>
  <Dir>Default</Dir>
  <PartImageSmall />
  <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
  <PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge>
  <IsIncludedFilter />
  <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
  <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
  <ContentLink xmlns="
http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
  <Content xmlns="
http://schemas.microsoft.com/WebPart/v2/ContentEditor">&lt;div&gt;​Access Denied.&#160; Please contact Administrator.&lt;/div&gt;</Content>
  <PartStorage xmlns="
http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart>
          ]]>
      </AllUsersWebPart>
    </File>

and with v3:

  <File Path="Pages\MeetingSearch.aspx" Url="MeetingSearch.aspx"  Type="GhostableInLibrary" ReplaceContent="TRUE" >
      <AllUsersWebPart WebPartZoneID="MainZone" ID="MeetingSearchWebPart" WebPartOrder="1">
        <![CDATA[<webParts>
  <webPart xmlns="
http://schemas.microsoft.com/WebPart/v3">
..
  </webPart>
</webParts>]]>
      </AllUsersWebPart>

v3 had extra <webparts> tag and v2 has extra attributes in WebPart tag.

Comments (1)

  1. Anon Developer says:

    Deepa, thank you! You hit the nail on the head. brilliant!

Skip to main content