An error occurred during dependency register - None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on t

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
I'm upgrading plugin from nopCommere 3.90 to 4.0

I've two plugin.
In first plugin I've service named "MyWebHelper"
(Plugin.My.Service.MyWebHelper)



And I'm using this service in another plugin.

In nopCommerce 3.9, it not required for register in dependency.

But in 4.0, it throws exception without dependency register.

So I tried to register it in second plugins DependencyRegister via below code, but it trowing exception.

Dependency Register

builder.RegisterType<MyWebHelper>().As<IMyWebHelper>().InstancePerLifetimeScope();


also tried with

  // Services
            builder.RegisterAssemblyTypes(typeof(IMyWebHelper).Assembly)
               //.Where(t => t.Name.EndsWith("Service"))
               .AsImplementedInterfaces()
               .InstancePerRequest();


Alos tried with


builder.RegisterType<MyWebHelper>().As<IMyWebHelper>().InstancePerLifetimeScope().
            //    WithParameter(ResolvedParameter.ForNamed<HttpContextBase>("nop_cache_static"));


My service constructor


  public partial class MyWebHelper : IMyWebHelper
    {
        private readonly HttpContextBase _httpContext;
      
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="httpContext">HTTP context</param>
        public MyWebHelper(HttpContextBase httpContext)
        {
            this._httpContext = httpContext;
        }
}



And error message is


An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = SolrWebHelper (ReflectionActivator), Services = [Plugin.My.Service.MyWebHelper], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Plugin.My.Service.MyWebHelper' can be invoked with the available services and parameters:
Cannot resolve parameter 'System.Web.HttpContextBase httpContext' of constructor 'Void .ctor(System.Web.HttpContextBase)'. (See inner exception for details.)




Anyone have idea where I'm doing wrong?
6 years ago
Now getting different error message

The requested service 'XcellenceIT.Plugin.Solr.Core.Domain.SolrWebHelper' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

Anyone have idea about this ?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.