The given key was not present in the dictionary

Vote:
 

Hello,

When I try to index a client's EPiServer site I often get the exception that the "given key was not present in the dictionary".  Does anyone know why the indexer job is throwing the exception?

Full error stack below.

Thanks

Danie

<exception><![CDATA[System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at EPiServer.Core.PageProviderBase.GetScatteredPages(IList`1 pageRefs, ILanguageSelector selector)
at EPiServer.Core.PageProviderBase.GetPagesBatched(IList`1 pageLinks, ILanguageSelector selector)
at EPiServer.DataFactory.GetPages(IList`1 pageLinks, ILanguageSelector selector)
at EPiServer.Find.Cms.PageDataExtensions.SearchSection(PageData page)
at EPiServer.Find.DelegateValueProvider`2.GetValue(Object target)
at EPiServer.Find.ClientConventions.FieldConventionBuilder`1.<>c__DisplayClass2.<>c__DisplayClass4.<ConvertBeforeSerializing>b__1(Object instance)
at EPiServer.Find.DelegateValueProvider.GetValue(Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value)
at EPiServer.Find.Api.BulkActionConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value)
at EPiServer.Find.Json.Serializer.SerializeToStringBuilder(JsonSerializer serializer, Object value, StringBuilder buffer)
at EPiServer.Find.Api.BulkCommand.Execute()
at EPiServer.Find.Client.Index(IEnumerable objectsToIndex)
at EPiServer.Find.Cms.PageIndexer.Index(IEnumerable`1 pages, IndexOptions options)

#73790
Aug 09, 2013 14:35
Vote:
 

There seems to be a problem with some of the pages in solution. You should be able to figure out which page is causing the problem by running the following code for all pages in the solution.

var ancestorLinks = DataFactory.Instance.GetParents(page.PageLink);
var ancestors = DataFactory.Instance.GetPages(ancestorLinks, LanguageSelector.AutoDetect(true));

#73970
Aug 15, 2013 20:50
Vote:
 

I ran into this recently (in a developer database), but for an image directly under the "for this site" root. Which caused all sort of problems in the edit mode as the image could not be loaded by the internal Episerver database API.

The error was that it could not find the language the image was supposedly created under, which we are still unsure how it happened.

Anyways, the only way we found to resolve the issue was to delete the content item from the database, and just using the IContentRepository did not work as that also threw an error when trying to access the fauly image. So to avoid fiddling around directly in the database, we used ContentStore instead, this way we could get rid of the faulty item, like so:

var contentStore = ServiceLocator.Current.GetInstance<EPiServer.DataAbstraction.ContentStore>();
contentStore.Delete(new ContentReference(xxx), true);

To find the actual faulty item in our case, we used GetDescendents, as GetChildren or any such method that returns an IContent instance would just throw an exception, and retrieved each item individually using IContentLoader.Get until we hit the faulty item throwing the exception.


So incase anyone else stumble upon this thread from google, like I did, the above might help.

#172172
Edited, Nov 25, 2016 10:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.