The given key was not present in the dictionary.


  • I have a problem after with the Content Query Webpart.
    The story is that we have taken a database backup, and restored it on the customers MOSS installation.

    All seems to work fine, except for the content query webpart, when we select “Modify Shared Webpart” we get the following error:

    The given key was not present in the dictionary.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 


    Stack Trace:
    [KeyNotFoundException: The given key was not present in the dictionary.]

       System.ThrowHelper.ThrowKeyNotFoundException() +28

       System.Collections.Generic.Dictionary`2.get_Item(TKey key) +2585456

       Microsoft.SharePoint.SPFieldCollection.CreateSPField(Int32 index) +1843

       Microsoft.SharePoint.SPFieldCollection.EnsureSPField(Int32 index) +61

       Microsoft.SharePoint.SPFieldCollection.get_Item(Int32 iIndex) +91

       Microsoft.SharePoint.SPFieldCollection.ItemAtIndex(Int32 iIndex) +29

       Microsoft.SharePoint.SPEnumerator.System.Collections.IEnumerator.get_Current() +28

       Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.populateData() +1523

       Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.populateCBQControls() +24

       Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.CreateChildControls() +62

       System.Web.UI.Control.EnsureChildControls() +87

       System.Web.UI.Control.PreRenderRecursiveInternal() +41

       System.Web.UI.Control.PreRenderRecursiveInternal() +161

       System.Web.UI.Control.PreRenderRecursiveInternal() +161

       System.Web.UI.Control.PreRenderRecursiveInternal() +161

       System.Web.UI.Control.PreRenderRecursiveInternal() +161

       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360


    It is only the Content Query Webpart that fails, all other webparts work fine.

    Bo Pfänner



    Monday, November 05, 2007 1:56 PM

All replies

  • Hi,

    In my case, my list was using a custom field that wasn't installed. (forgot to install it in my new environnement)
    I just installed the custom field and it was working.

    Merlin Martel
    Tuesday, September 22, 2009 6:38 PM