Try our conversational search powered by Generative AI!

How to setup EPiFind Personalization in .NET 6


I'm trying to setup Personalized Search & Navigation (formerly Personalized Find) following this guide in the link,

What I've done so far are;

- Installed the Integration packages
- Configure the attributes in appsettings.json 
- Retrieve attributes using [EPiServer.Find.Personalization.RefreshPreferences]
- execute the personalized search queries using UsingPersonalization()

Upon starting the site I encountered this error below.

Is there anything else to setup?

Versions used:
- .NET 6
- EPiServer.CMS.AspNetCore 12.12.1
- EPiServer.Personalization.Commerce 4.0.20
- EPiServer.Find.Personalization 15.0.0

Edited, Sep 08, 2023 2:10

You are initializing correctly, Check if find settings exist in your appSettings.*.json

Sep 08, 2023 8:45
Dan Paloma - Sep 08, 2023 9:43
Thanks for your reply. I does exist, the issue we have in Find is with UsingPersonalization() only.

Can you post the full stacktrace?

Sep 08, 2023 9:16
Dan Paloma - Sep 08, 2023 9:29
Thanks for your reply. Please see below.

at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at EPiServer.Find.Personalization.RefreshPreferencesAttribute..ctor()
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Boolean inherit)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.<>c.

By the way this was our error before we encounter the error mentioned in this topic.

The error below shows with these steps;
- Installed the Integration packages 
  > EPiServer.Personalization.Commerce 4.0.20
  > EPiServer.Find.Personalization 15.0.0
- execute the personalized search queries using UsingPersonalization()

[ERR] [EPiServer.Find.Personalization.Api.RefreshPreferenceCommand] Could not execute the refresh command. Personalization unreliable. Error: Object reference not set to an instance of an object.

Edited, Sep 08, 2023 9:46

If seems you have a problem with circular reference. Your startup tries to add Commerce, which adds Cms, which adds CmsHost, which initializes your site, and try to initialize some attributes, which tries to get an instance of IClient, which will not be registered until you call AddFind().

I think that you can try to add this before AddCommerce or even AddCms

services.AddSingleton<IClient, Client>();

untested of course, but you can try 

Sep 08, 2023 11:14
* 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.