We have changed the Dependency Injector in our Sitecore 9.1 solution to use Autofac, following this description: https://doc.sitecore.com/developers/90/sitecore-experience-management/en/dependency-injection.htmlthis description as as well as receiving a support .dll from Sitecore support.
We register our types using this configurator code:
public class SitecoreExtensionsConfigurator : IServicesConfigurator
{
public void Configure(IServiceCollection serviceCollection)
{
serviceCollection.AddTransient<ITrackerService, TrackerService>();
serviceCollection.AddSingleton<IRenderingPropertiesRepository, RenderingPropertiesRepository>();
}
}
However, as far as I understand it, it just uses the Microsoft DI framework to register the types. What if I want to register my components using Autofac syntax, like:
public void Configure(IServiceCollection serviceCollection)
{
var builder = new ContainerBuilder();
builder.RegisterType<TrackerService>()
.As<ITrackerService>();
}
However, that makes my site fail, with an exception, stating that ITrackerService is not registeredITrackerService is not registered
.