Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've incorporated the starter kit product page into our site, but its falling over on this line:
List<VariantPublishedContent> variants = TC.GetVariants(storeId, Model, true).ToList();
The error is:
The requested service 'TeaCommerce.Umbraco.Configuration.Variants.Services.IVariantService`2[[Website.Core.Models.DocumentTypes.ProductDetailPage, Website.Core, Version=18.104.22.168, Culture=neutral, PublicKeyToken=null],[TeaCommerce.Umbraco.Configuration.Variants.Models.VariantPublishedContent, TeaCommerce.Umbraco.Configuration, Version=3.3.6977.16237, Culture=neutral, PublicKeyToken=null]]' 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.
We're using Autofac for our DI and this is how its setup:
public static void RegisterDependencies()
var builder = new ContainerBuilder();
// register all controllers found in your assembly
// register controllers from other Plugin DLL's otherwise they might break the back office
// register Umbraco MVC + web API controllers used by the admin site
// Register custom services etc.
builder.Register(c => new EmailService()).As<IEmailService>().InstancePerLifetimeScope();
var container = builder.Build();
var resolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
These are the DLL's in the bin folder:
Any ideas what I'm doing wrong??
TC uses AutoFac for it's DI container also so I'm guessing you've likely replaced the builder instance thus removed all of TC's dependency registrations.
This is the line in TCForUmbraco that triggers all of TC's DI configuration:
I'd probably suggest calling this and adding in a reference to your DLL and then use AutoFac Modules to define your custom registrations (as this is what the TC DependencyContainer looks for).
So replace my current DI setup with:
and create a module like:
public class ServicesConfig : Module
protected override void Load(ContainerBuilder builder)
builder.RegisterType<EmailService>().As<IEmailService>().PreserveExistingDefaults<EmailService, ConcreteReflectionActivatorData, SingleRegistrationStyle>().InstancePerLifetimeScope();
how do I register that Module outside of the TeaCommerce code?
I tried adding this code to my ApplicationStarted method:
ModuleRegistrationExtensions.RegisterAssemblyModules(builder, new Assembly
but I can't get access to "builder"
DependencyContainer.Configure should do the loading of the modules for you. Inside each module you have access to the builder to register your types.
DependencyContainer.Configure should be called from within a ApplicationEventHandler much like the one in the TC4Umbraco.
When you call DependencyContainer.Configure, be sure to also include the TC4Umbraco assembly's as well.
Full disclosure, I'm not overly familiar with Autofac so I have asked Run from TeaSolutions to see if he wouldn't mind coming to have a look at this and just double check what I'm suggesting is correct. Hopefully he will be able to confirm.
Hm. That's a good question. So as I read it Ian, you are doing your own autofac and that might be messing with the TC autofac. And yes, it does look like you might be overwriting the something important, although TC does it a little different.
Have you first of all confirmed that it's your own code that messes with TC?
Maybe have a look at how TC registers it's types:
You might be able to do it the same way.
I've removed any reference to Autofac and any DI code in my solution. I've also reinstalled TC 3.3 but I'm still getting the same error when trying to access TC.GetVariants(storeId, Model, true).ToList()
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted