Foundation NuGet package upgrade then error

Vote:
 

Hi, I upgraded my Foundation project to the latest stable NuGet packages, and now when I run the program is crashes on 

CreateHostBuilder(args, isDevelopment).Build().Run();

with the error "ArgumentException: An item with the same key has already been added. Key: SearchAdmins".

I cannot find a reason for this - does anyone know how to resolve this?

Thanks

Chris

Update 1: I found that if I commented out this:             //services.AddFind(); in Startup.cs I do not get the error.
This is a multi-site setup so maybe that has something to do with the code trying to add "SearchAdmins" twice.
Yet you would think the underlying code would be handling duplicates.
I See the last line is at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
which by the name "TryInsert" I would think it would be graceful enough to not crash on this.
Since I got the site(s) running, I was looking around for a user or group named "SearchAdmins" but cannot find one.

System.ArgumentException: An item with the same key has already been added. Key: SearchAdmins
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.<>c.<AddFind>b__0_5(MappedRolesOptions o)
   at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(String name, TOptions options)
   at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
   at Microsoft.Extensions.Options.UnnamedOptionsManager`1.get_Value()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at EPiServer.Framework.FrameworkInitialization.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()

#329724
Edited, Sep 11, 2024 19:41
Vote:
 

I will look into this and log a bug to Find team if needed. Thanks for bringing it to our attention 

#329768
Sep 12, 2024 7:41
Vote:
 

It seems our colleagues were already aware of this issue. The cause was AddContentSearchApi() already called AddFind(), so you can remove AddFind() and it should be fine for the time being

#329770
Sep 12, 2024 10:36
Vote:
 

Thank you!

Chris

#329778
Sep 12, 2024 19:21
* 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.