Today I decided to add a dependency to it so I can use the IProductService. I had no constructor before because I didn't need anything so I added one as you would expect. Now when I loaded my site via VS, it fails on the first Controller it can fine because of a missing parameterless constructor. I narrowed it down to my IExcelService. If I remove the constructor, everything works.
I know I have it registered because I made my own DependencyRegistrar class and I can see it executing. What am I missing?
public partial class ExcelService : IExcelService
{
private IProductService _productService;
public ExcelService(IProductService productService)
{
this._productService = productService;
}
public virtual byte[] AGreatFunction()
{ }
}
public class ASCDependencyRegistrar : IDependencyRegistrar
{
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterType<ASCImportManager>().As<IImportManager>().InstancePerHttpRequest();
builder.RegisterType<ASCWorkflowMessageService>().As<IWorkflowMessageService>().InstancePerHttpRequest();
builder.RegisterType<ASCMessageTokenProvider>().As<IMessageTokenProvider>().InstancePerHttpRequest();
builder.RegisterType<ASCPriceCalculationService>().As<IPriceCalculationService>().InstancePerHttpRequest();
builder.RegisterType<ASCProductService>().As<IProductService>().InstancePerHttpRequest();
builder.RegisterType<ExcelService>().As<IExcelService>().InstancePerHttpRequest();
}
public int Order
{
get { return 1; }
}
}
Any code that is touching the ExcelService is loading IExcelService in it's constructor.
I'm working around it right now by using
_productService = Nop.Core.Infrastructure.EngineContext.Current.Resolve<IProductService>();in my function but that's not ideal.