Join me at Google+ ...

Writing tons of xml in order to create SharePoint 2007 site columns and getting and error “The given key was not present in the dictionary.” after deployment isn’t the thing I want to get at the end of the day.

After doing some review I found the error which can easily be missed.

Problem description

This is the error I got after deployment which isn’t really helpful:

image

It doesn't tell us which key and which directory...

This is the text:

The given key was not present in the dictionary.   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Microsoft.SharePoint.SPFieldCollection.CreateSPField(Int32 index)
   at Microsoft.SharePoint.SPFieldCollection.EnsureSPField(Int32 index)
   at Microsoft.SharePoint.SPFieldCollection.get_Item(Int32 iIndex)
   at Microsoft.SharePoint.SPFieldCollection.ItemAtIndex(Int32 iIndex)
   at Microsoft.SharePoint.SPBaseCollection.SPEnumerator.System.Collections.IEnumerator.get_Current()
   at Microsoft.SharePoint.ApplicationPages.FieldListRenderer.OnPreRender(EventArgs e)
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Solution

After deleting every field step by step I found that the following field was creating the error:

  <Field ID="{CA57B137-76C9-47e1-A49C-BEA5D819081B}" Name="NAME1"
         Type="Url" DisplayName="DISPLAYNAME" Group="GROUP"
         AllowDeletion="False" Sealed="TRUE" Format="Hyperlink" />

After reviewing that the type=”Url” is case sensitive and needs to be all uppercase type=”URL”:

  <Field ID="{CA57B137-76C9-47e1-A49C-BEA5D819081B}" Name="NAME2"
         Type="URL" DisplayName="DISPLAYNAME" Group="GROUP"
         AllowDeletion="False" Sealed="TRUE" Format="Hyperlink" />

Just a little mistake which can take a lot of time to find… I hope it saves time for someone else.



Get updates

 

Comments (2) -

3/15/2011 11:43:57 AM #

Hi There

In your Solution Above you stated the following "After deleting every field step by step I found that the following field was creating the error:"

Sorry just a few Questions:

1)When you say "After deleting every field step by step" what XML file are you refering to?

2)Or is this field somewhere to be found in the Sharepoint Database?

Regards

Zunaid South Africa Reply

3/15/2011 1:21:21 PM #

Hi,

I'm referring to fields (which represent columns) in the schema.xml... I created a custom schema.xml within a feature. After deploying and testing the feature with the custom list / schema.xml the error occurred.
Since I knew what I changed I removed the fields from the schema.xml and deployed / tested it again until it worked. So at the end I found the field (see XML code under solution in the article) in the schema.xml which was creating problems and after carefully checking the line I found the problem.

I didn't change anything in the database.

Regards

Andreas Glaser Switzerland Reply

Pingbacks and trackbacks (1)+

Add comment




  Country flag
biuquote
Loading