I want to override some current method using plugin, but i am getting error.
my current DependencyRegistrar code is below
using Autofac;
using Autofac.Core;
using Autofac.Integration.Mvc;
using Nop.Core.Data;
using Nop.Core.Infrastructure;
using Nop.Core.Infrastructure.DependencyManagement;
using Nop.Data;
using Nop.Plugin.Pricing.PreciousMetals.Data;
using Nop.Plugin.Pricing.PreciousMetals.Domain;
using Nop.Plugin.Pricing.PreciousMetals.Services;
using Nop.Services.Catalog;
using Nop.Services.Orders;
using Nop.Web.Framework.Mvc;
namespace Nop.Plugin.Pricing.PreciousMetals
{
public class DependencyRegistrar : IDependencyRegistrar
{
const string objectContextName = "nop_object_context_preciousmetals_pricing";
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//data layer
var dataSettingsManager = new DataSettingsManager();
var dataProviderSettings = dataSettingsManager.LoadSettings();
const string objectContextName = "nop_object_context_preciousmetals_pricing";
if (dataProviderSettings != null && dataProviderSettings.IsValid())
{
//register named context
builder.Register<IDbContext>(c => new PreciousMetalsPricingObjectContext(dataProviderSettings.DataConnectionString))
.Named<IDbContext>(objectContextName)
.InstancePerLifetimeScope();
builder.Register(c => new PreciousMetalsPricingObjectContext(dataProviderSettings.DataConnectionString))
.InstancePerLifetimeScope();
}
else
{
//register named context
builder.Register<IDbContext>(c => new PreciousMetalsPricingObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.Named<IDbContext>(objectContextName)
.InstancePerLifetimeScope();
builder.Register(c => new PreciousMetalsPricingObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.InstancePerLifetimeScope();
}
// register custom objects
builder.RegisterType<EfRepository<PreciousMetalsDetail>>()
.As<IRepository<PreciousMetalsDetail>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>(objectContextName))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<PreciousMetalsQuote>>()
.As<IRepository<PreciousMetalsQuote>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>(objectContextName))
.InstancePerLifetimeScope();
//Register services
builder.RegisterType<PreciousMetalsDetailService>().As<IPreciousMetalsDetailService>().InstancePerLifetimeScope();
builder.RegisterType<PreciousMetalsQuoteService>().As<IPreciousMetalsQuoteService>().InstancePerLifetimeScope();
builder.RegisterType<PreciousMetalsPriceCalculationService>().As<IPriceCalculationService>().InstancePerLifetimeScope();
builder.RegisterType<PreciousMetalsOrderTotalCalculationService>().As<IOrderTotalCalculationService>().InstancePerLifetimeScope();
builder.RegisterType<PreciousMetalsProductService>().As<IProductService>().InstancePerLifetimeScope();
}
public int Order
{
get { return 1; }
}
}
}
Server Error in '/' Application.
Circular component dependency detected: Nop.Web.Controllers.CatalogController -> Nop.Web.Controllers.CatalogController -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsProductService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsProductService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsPriceCalculationService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsPriceCalculationService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsProductService.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Autofac.Core.DependencyResolutionException: Circular component dependency detected: Nop.Web.Controllers.CatalogController -> Nop.Web.Controllers.CatalogController -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsProductService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsProductService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsPriceCalculationService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsPriceCalculationService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsProductService.
Source Error:
Line 6: @Html.Widget("home_page_top")
Line 7: @Html.Action("TopicBlock", "Topic", new { systemName = "HomePageText" })
Line 8: @Html.Action("HomepageCategories", "Catalog")
Line 9: @Html.Action("HomepageProducts", "Product")
Line 10: @Html.Action("HomepageBestSellers", "Product")
Source File: e:\MyProjects\nopCommerce_3.40_Source\Presentation\Nop.Web\Views\Home\Index.cshtml Line: 8
Stack Trace:
[DependencyResolutionException: Circular component dependency detected: Nop.Web.Controllers.CatalogController -> Nop.Web.Controllers.CatalogController -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsProductService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsProductService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsPriceCalculationService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsPriceCalculationService -> Nop.Plugin.Pricing.PreciousMetals.Services.PreciousMetalsProductService.]
Autofac.Core.Resolving.CircularDependencyDetector.CheckForCircularDependency(IComponentRegistration registration, Stack`1 activationStack, Int32 callDepth) +431
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +158
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +72
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +82
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +233
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +563
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +109
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +63
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +201
Autofac.Core.Resolving.InstanceLookup.Execute() +262
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +282
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +72
Autofac.Core.Registration.<>c__DisplayClass8.<RegistrationsFor>b__3(IComponentContext c, IEnumerable`1 p) +57
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +191
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +109
Autofac.Core.Resolving.InstanceLookup.Execute() +158
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +282
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +72
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +82
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +233
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +563
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +109
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +63
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +201
Autofac.Core.Resolving.InstanceLookup.Execute() +262
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +282
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +72
Autofac.Core.Registration.<>c__DisplayClass8.<RegistrationsFor>b__3(IComponentContext c, IEnumerable`1 p) +57
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +191
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +109
Autofac.Core.Resolving.InstanceLookup.Execute() +158
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +282
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +72
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +82
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +233
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +563
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +109
Autofac.Core.Resolving.InstanceLookup.Execute() +158
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +282
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +72
Autofac.Core.Registration.<>c__DisplayClass8.<RegistrationsFor>b__3(IComponentContext c, IEnumerable`1 p) +57
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +191
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +109
Autofac.Core.Resolving.InstanceLookup.Execute() +158
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +282
Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +60
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +111
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +278
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +175
Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters) +243
Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable`1 parameters) +72
Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType) +48
Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type serviceType) +57
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +87
[InvalidOperationException: An error occurred when trying to create a controller of type 'Nop.Web.Controllers.CatalogController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +247
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +438
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +257
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +326
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +157
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +88
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +50
System.Web.Mvc.<>c__DisplayClass7.<BeginProcessRequest>b__6() +81
System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +69
System.Web.Mvc.ServerExecuteHttpHandlerAsyncWrapper.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +169
System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +2019
System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +76
System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +28
System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +19
System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) +985
System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) +112
System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName) +46
ASP._Page_Views_Home_Index_cshtml.Execute() in e:\MyProjects\nopCommerce_3.40_Source\Presentation\Nop.Web\Views\Home\Index.cshtml:8
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +122
System.Web.WebPages.StartPage.RunPage() +63
System.Web.WebPages.StartPage.ExecutePageHierarchy() +100
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +131
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +695
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +382
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +431
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +321
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9690172
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009
Please help me.
Thanks in advance.