Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

[NullReferenceException: Object reference not set to an instance of an object.]

Vote:
 

Hi,

I am getting NullReferenceException with the below message when trying to retrieve some data from EPI find. Can some one help me to resolve this issue.I got struck for long time with this issue.

I have given below message too lengthy because make you understand where i got stuck. Please help me in this regard.

[NullReferenceException: Object reference not set to an instance of an object.]
at EPiServer.DefaultContentProvider.GetLanguageId(ILanguageSelector selector)
at EPiServer.DefaultContentProvider.<>c__DisplayClass14_0.b__0(IList`1 refs)
at EPiServer.DefaultContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
at EPiServer.DefaultContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
at EPiServer.Core.ContentProvider.GetScatteredContents(IEnumerable`1 contentLinks, ILanguageSelector selector)
at EPiServer.Core.ProviderPipelineImplementation.GetItems(ContentProvider provider, IList`1 contentLinks, LoaderOptions loaderOptions)
at EPiServer.Core.DefaultContentLoader.GetItems(IEnumerable`1 contentLinks, LoaderOptions loaderOptions)
at EPiServer.Find.Cms.SearchRequestExtensions.GetContentResult[TContentData](ITypeSearch`1 search, Int32 cacheForSeconds, Boolean cacheForEditorsAndAdmins)
at Corporate.Web.Search.Find.FindHelper.GetNewsItemPage(Int32 totalItems)
at Corporate.Web.Controllers.Pages.NewsEventsPageController.Index(NewsEventsPage currentPage)

#152617
Aug 26, 2016 11:45
Vote:
 

Looks like you have some weird language problem on some content item. It finds a bunch of items and then tries to load them but bombs when trying to get the languageId for one of them?

Try turn on logging on info level and see if that helps. Try to go through items and delete any language versions you aren't using...

Did you do anything to language settings recently? Like disabled some language / add fallback language or similar?

#152624
Aug 26, 2016 12:34
Vote:
 

After going through the error Ihave seen that error is coming from the EPifind method GetContentResult and it seems that language selector object is null. When we see the documentation it is written that The GetContentResult method automatically filters search requests to select content from the current language, as determined by the Episerver LanguageSelector.Autodetect() method. To select pages from a different language branch, use an overload accepting a LanguageSelector instance.

In my code i also have not used any LanguageSelector object as i want content from current language

var result = SearchClient.Instance.Search<ListablePage>().FilterForVisitor().
Take(totalItems).Filter(x => x.MatchType(typeof(NewsItemPage)) |
x.MatchType(typeof(PressReleasePage))).GetContentResult().OrderByDescending(x =>x.StartPublish).ToList();

Could you please help on this.

#152636
Aug 26, 2016 14:36
Vote:
 

Hmm tricky. Tried sending in the current language as a separate filter just to try...?

#152637
Aug 26, 2016 14:44
Vote:
 

Hi Daniel,

Just now i have cleaned Indexing and reindexing again ..Now its working........ 

Thanks for your advise and Help.

Sourav

#152638
Aug 26, 2016 15:22
Vote:
 

Ok. Probably a language version of a page that was present in index but not in site for some reason I guess. Nice that you were able to solve it!

#152639
Aug 26, 2016 15:25
* 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.