Hi, I read the code of 1.9 version but I have no clue how to inject NopObjectContext in service class constructors? or on the other hand in witch section of code (or witch class) NopCommerce has specified inject NopObjectContext to service class constructors?
I have the following code but am getting an error during Resolve
public void InsertProducts() { Product OP = new Product(); OP.Name = "Bla"; OP.ShortDescription = "efwfewf";
NopConfig.Init(); IoC.InitializeWith(new DependencyResolverFactory()); var oPSvc = IoC.Resolve<IProductService>(); oPSvc.InsertProduct(OP); }
Resolution of the dependency failed, type = "NopSolutions.NopCommerce.BusinessLogic.Products.IProductService", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type NopObjectContext has multiple constructors of length 1. Unable to disambiguate. ----------------------------------------------- At the time of the exception, the container was:
Resolving NopSolutions.NopCommerce.BusinessLogic.Products.ProductService,(none) (mapped from NopSolutions.NopCommerce.BusinessLogic.Products.IProductService, (none)) Resolving parameter "context" of constructor NopSolutions.NopCommerce.BusinessLogic.Products.ProductService(NopSolutions.NopCommerce.BusinessLogic.Data.NopObjectContext context) Resolving NopSolutions.NopCommerce.BusinessLogic.Data.NopObjectContext,(none)
If your service is RESTFUL service then it will not work...of it is standard web service....then thers is one section in web named....nopconfig (dnt remember the exact name as i dnt have source code with me right)....u jst need to include that section in ur project web.config....or jst copy the same connection string in ur project....i mean connection string in NopCommerce web site......
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.