Point Deep

Mundeep's Tech Blog

Value does not fall within the expected range

Posted by mundeep on August 14, 2008

I was debugging a problem today where i would get the following error recently when trying to associate a content type with a document library:

Value does not fall within the expected range. at Microsoft.SharePoint.SPFileCollection.get_Item(String urlOfFile)
at Microsoft.SharePoint.SPContentTypeCollection.Add(SPContentType contentType)
at Microsoft.SharePoint.ApplicationPages.AddContentTypeToListPage.Update(Object o, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

After examining the elements.xml and confirming that (a) all the bound content types exists and (b) all the site columns used by the content types existed, i noticed that there was a mis-match in the name of the content-type and the url used in the module to deploy the document template. A snippet of the elements.xml specific to one of the content-types is shown below.

  <ContentType Name="Briefing (Event)" Group="Custom Document Content Types" Description="" ID="0x0101002DB264DB4656424CB8247FDE6BA03F7E021C">
    <FieldRefs>
      <FieldRef ID="{52578fc3-1f01-4f4d-b016-94ccbcf428cf}" Name="Comments" />
      <FieldRef ID="{cd94be8c-d754-4a6d-865d-7cb40375b11c}" Name="Document Status" />
	  ...
      <FieldRef ID="{130da223-b498-417c-9bdd-1fc2ac43aa6e}" Name="Country" />
    </FieldRefs>
    <DocumentTemplate TargetName="Briefing_template.doc" />
  </ContentType>
  <Module Name="Briefing" Url="_cts/Briefing" RootWebOnly="true">
    <File Url="Briefing_template.doc" Name="Briefing_template.doc" Type="Ghostable" />
  </Module>

The mistake was that the Url=”_cts/Briefing” property of the module should have been Url=”_cts/Briefing (Event)” to match the Name of the content-type.

Update: I also ran into the same error on another content type where the name of the template file in the tag did not match the actual filename.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: