To populate NopCommerce with products and categories I made a WCF service that can be called from an external system.
To use the CategoryService and ProdcutService I use:
ICategoryService categoryService = IoC.Resolve<ICategoryService>();
IProductService productService = IoC.Resolve<IProductService>();
If I use this code from an aspx page in e.g. PageLoad everything works fine and I get the two services.
If I use this code from a method within a WCF service I always get an exception "Unable to cast object".
In this case more specifically:
Unable to cast object of type 'NopSolutions.NopCommerce.BusinessLogic.Data.NopObjectContext' to type 'NopSolutions.NopCommerce.BusinessLogic.Products.IProductService'.
The first call to IoC.Resolve always seems to work, all after that fails (if I switch the 2 lines of code around I get the ProductService and an exception on the CategoryService).
How do I use IoC.Resolve from WCF without getting exceptions?
Thanks,
Jan.