0

I'm trying to replicate the federated auth from habitat using the Facebook example, and parlay that into auth with Salesforce. I can't get around this dependency injection error though.

Starting with the stack trace:

[InvalidOperationException: Unable to resolve service for type 'System.Collections.Generic.IList`1[Client.Feature.Membership.Services.FacetUpdaters.IContactFacetUpdater]' while attempting to activate 'Client.Feature.Membership.Services.UpdateContactFacetsService'.]
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) +443
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(Type serviceType, Type implementationType, CallSiteChain callSiteChain) +396
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain) +172
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain) +78
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain) +157
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) +109
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(Type serviceType, Type implementationType, CallSiteChain callSiteChain) +396
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain) +172
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain) +78
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain) +157
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) +109
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(Type serviceType, Type implementationType, CallSiteChain callSiteChain) +396
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain) +172
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain) +78
   Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain) +157
   Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor(Type serviceType) +97
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +88
   Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) +46
   Sitecore.Mvc.Controllers.SitecoreDependencyResolver.GetService(Type serviceType) +41
   Sitecore.Mvc.Controllers.SitecoreControllerFactory.ResolveController(Type type) +46
   Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(RequestContext requestContext, String controllerName) +95

[ControllerCreationException: Could not create controller: 'Client.Feature.Membership.Controllers.MembershipController, Client.Feature.Membership'. 
The context item is: '/sitecore/content/Client/Home/Sample'. 
The current route url is: '{*pathInfo}'. This is the default Sitecore route which is set up in the 'InitializeRoutes' processor of the 'initialize' pipeline. ]
   Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(RequestContext requestContext, String controllerName) +171
   Sitecore.Mvc.Controllers.ControllerRunner.GetController() +23
   Sitecore.Mvc.Controllers.ControllerRunner.Execute(TextWriter writer) +39
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +147
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +74
   (Object , Object ) +14
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +490
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +236
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +195
   Sitecore.Mvc.Pipelines.Response.RenderPlaceholder.PerformRendering.Render(String placeholderName, TextWriter writer, RenderPlaceholderArgs args) +192
   (Object , Object ) +14
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +490
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +236
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +195
   Sitecore.Mvc.Helpers.SitecoreHelper.RenderPlaceholderCore(String placeholderName, TextWriter writer) +250
   Sitecore.Mvc.Helpers.SitecoreHelper.Placeholder(String placeholderName) +61
   ASP._Page_Views_Navigation_Header_cshtml.Execute() in C:\inetpub\wwwroot\Client.dev.local\Views\Navigation\Header.cshtml:42
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +91
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +698

The class in question:

[Service(typeof(IUpdateContactFacetsService))]
public class UpdateContactFacetsService : IUpdateContactFacetsService
{
    /// <summary>
    /// The XDB context factory.
    /// </summary>
    private readonly IXdbContextFactory _xdbContextFactory;

    /// <summary>
    /// The contact manager.
    /// </summary>
    private readonly IContactManagerService _contactManager;

    /// <summary>
    /// The facet updaters.
    /// </summary>
    private readonly IList<IContactFacetUpdater> _facetUpdaters;

    /// <summary>
    /// Initializes a new instance of the <see cref="UpdateContactFacetsService"/> class.
    /// </summary>
    /// <param name="xdbContextFactory">The XDB context factory.</param>
    /// <param name="contactManager">The contact manager.</param>
    /// <param name="facetUpdaters">The facet updaters.</param>
    public UpdateContactFacetsService(IXdbContextFactory xdbContextFactory, IContactManagerService contactManager, IList<IContactFacetUpdater> facetUpdaters)
    {
        Assert.ArgumentNotNull(xdbContextFactory, nameof(xdbContextFactory));
        Assert.ArgumentNotNull(contactManager, nameof(contactManager));
        Assert.ArgumentNotNull(facetUpdaters, nameof(facetUpdaters));
        Assert.ArgumentCondition(facetUpdaters.Any(), nameof(facetUpdaters), $"{nameof(facetUpdaters)} must not be empty");
        _xdbContextFactory = xdbContextFactory;
        _contactManager = contactManager;
        _facetUpdaters = facetUpdaters;
    }
0

I changed a few things and can no longer replicate the error. Most likely candidates:

1) Associated the site to the identity provider:

<sitecore>
    <federatedAuthentication>
      <identityProvidersPerSites>
        <mapEntry name="ClientSitecom" type="Sitecore.Owin.Authentication.Collections.IdentityProvidersPerSitesMapEntry, Sitecore.Owin.Authentication">
          <sites hint="list">
            <site>ClientSitecom</site>
          </sites>
          <identityProviders hint="list:AddIdentityProvider">
            <identityProvider ref="federatedAuthentication/identityProviders/identityProvider[@id='Facebook']"/>
          </identityProviders>
          <externalUserBuilder type="Sitecore.Owin.Authentication.Services.DefaultExternalUserBuilder, Sitecore.Owin.Authentication">
            <param desc="isPersistentUser">true</param>
          </externalUserBuilder>
        </mapEntry>
      </identityProvidersPerSites>
    </federatedAuthentication>
    <sites>

2) ensure the ServiceRegistration in the Account feature was populating the correct properties of IContactFacetUpdater

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.