Friday, April 8, 2011

Unable to locate the xml-definition for CType with SPContentTypeId

When deploying your SharePoint solution to your development or test server where solution has been deployed before you may find errors like these in SharePoint log: Unable to locate the xml-definition for CType with SPContentTypeId <Content type ID here> and Failed to find the content type schema for ct-0-0x010100<Content type ID> during template lookup.

Symptoms

The exact reason for these errors is still unknown to me but symptom is clear: I have seen these errors happen in environments where deployed package was deployed before. I have seen this problem happen on development and test environments mainly. For production deployments you should anyway start with clean installation of servers and handle all deployments with special care.

As this error is not directly shown you when you deploy your solution you may detect it later through weird behavior of layout pages. When adding new publishing page to pages library you may get unexpected errors. From logs you can find errors stated above.

Solution

NB! Before applying the fix to your solution make sure you make backups of SharePoint and test these changes completely so you are 100% sure that these changes doesn’t have negative side effects on data you already have.

To get over these errors I added Overwrite=”TRUE” to problematic content type definition.


<ContentType  ID="0x010100C568DB52D9D0A14D9B2FDCC142166E9F2" Name="$Resources:my,MyCT_Name" Description="$Resources:my,MyCT_Description" Group="My" Overwrite="TRUE" Inherits="TRUE" Version="0">   <FieldRefs>     <FieldRef ID="{C7B4C971-3AE9-46FF-9354-13E31ADD9C30}" Name="Age"/>     <FieldRef ID="{E2DDA75E-C9E0-4D8F-A489-71C764293E47}" Name="Income"/>   </FieldRefs> </ContentType>

After these changes deployment succeeded with no problems on content types.

No comments:

Post a Comment