I built my own serviceProviderBuilder
using StructureMap and replaced the default one from Sitecore.
public class StructureMapServiceProviderBuilder : BaseServiceProviderBuilder
{
protected override IServiceProvider BuildServiceProvider(IServiceCollection serviceCollection)
{
var container = new Container();
container.Populate(serviceCollection);
return container.GetInstance<IServiceProvider>();
}
}
In Sitecore logs I see the following error from StructureMap (complaining about BaseAuthenticationManager
):
Exception: StructureMap.Building.StructureMapBuildException
Message: Bi-directional dependency relationship detected!
Check the StructureMap stacktrace below:
1.) Container.GetInstance(Sitecore.Abstractions.BaseAuthenticationManager)
2.) Lambda: Invoke(value(StructureMap.ContainerExtensions+<>c__DisplayClass9_0).descriptor.ImplementationFactory, IContext.GetInstance())
3.) Instance of Sitecore.Owin.Authentication.Configuration.FederatedAuthenticationConfiguration (System.Object)
4.) new AuthenticationManager(*Default of BaseCacheManager*, *Default of BaseTicketManager*, *Default of ProviderHelper<AuthenticationProvider, AuthenticationProviderCollection>*, *Default of AuthenticationSourceResolver*, *Default of AuthenticationTypeResolver*, *Default of FederatedAuthenticationConfiguration*, *Default of ApplicationUserFactory*, *Default of UserFactory*, *Default of ExternalLogoutManager*)
5.) Sitecore.Owin.Authentication.Security.AuthenticationManager
6.) Instance of Sitecore.Owin.Authentication.Security.AuthenticationManager
7.) Container.GetInstance(Sitecore.Owin.Authentication.Security.AuthenticationManager)
8.) Container.TryGetInstance(Sitecore.Owin.Authentication.Security.AuthenticationManager)
9.) Lambda: Invoke(value(StructureMap.ContainerExtensions+<>c__DisplayClass9_0).descriptor.ImplementationFactory, IContext.GetInstance())
10.) Instance of Sitecore.Abstractions.BaseAuthenticationManager (System.Object)
11.) Container.GetInstance(Sitecore.Abstractions.BaseAuthenticationManager)
Source: Anonymously Hosted DynamicMethods Assembly
at lambda_method(Closure , IBuildSession , IContext )
at StructureMap.Building.BuildPlan.Build(IBuildSession session, IContext context) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\Building\BuildPlan.cs:line 152
at StructureMap.Pipeline.LifecycleObjectCache.Get(Type pluginType, Instance instance, IBuildSession session) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\Pipeline\LifecycleObjectCache.cs:line 71
at StructureMap.SessionCache.GetObject(Type pluginType, Instance instance, ILifecycle lifecycle) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\SessionCache.cs:line 93
at StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\SessionCache.cs:line 68
at StructureMap.Container.GetInstance(Type pluginType) in C:\BuildAgent\work\a395dbde6b793293\src\StructureMap.Shared\Container.cs:line 720
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Sitecore.DependencyInjection.LazyResetable`1.get_Value()
at Sitecore.Context.ContextData.get_User()
at Sitecore.Security.AccessControl.ItemAccess.CanRead()
at Sitecore.Data.Managers.ItemProvider.ApplySecurity(Item item, SecurityCheck securityCheck)
at Sitecore.ContentTesting.Pipelines.ItemProvider.GetItem.GetItemUnderTestProcessor.Process(GetItemArgs args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Data.Managers.DefaultItemManager.GetItem(String itemPath, Language language, Version version, Database database, SecurityCheck securityCheck)
at Sitecore.Data.Managers.DefaultItemManager.GetItem(String itemPath, Language language, Version version, Database database)
at Sitecore.Data.Managers.ItemManager.GetItem(String itemPath, Language language, Version version, Database database)
at Sitecore.Globalization.DictionaryDomain.GetDomainDefinitionItem(Database database, String name)
at Sitecore.Globalization.DictionaryDomain.TryParse(String domainDefinition, Database database, DictionaryDomain& domain)
at Sitecore.Globalization.DictionaryDomain.GetDefaultDomain(Database database)
at Sitecore.Pipelines.GetTranslation.TryGetFromContextDatabase.Process(GetTranslationArgs args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, Boolean failIfNotExists)
at Sitecore.Globalization.DefaultTranslate.TextByLanguage(String domainName, TranslateOptions options, String key, Language language, String defaultValue, Object[] parameters)
at Sitecore.Globalization.DefaultTranslate.TextByLanguage(String key, Language language, String defaultValue, Object[] parameters)
at Sitecore.Globalization.Translate.TextByLanguage(String key, Language language, String defaultValue, Object[] parameters)
at Sitecore.Abstractions.BaseJobStatus.LogInfo(String message, Object[] args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Jobs.DefaultJob.DoExecute()
at Sitecore.Abstractions.BaseJob.ThreadEntry(Object state)
Do you know any extra configuration which should be done to make it work with StructureMap?