Common Service Locator

The Autofac.Extras.CommonServiceLocator package allows you to use Autofac as the backing store for services in places where you require Microsoft Common Service Locator integration.

The Autofac.Extras.CommonServiceLocator package will also work in conjunction with the Autofac Microsoft Enterprise Library integration package.

To use the Common Service Locator integration, build your Autofac container as normal, then simply set the current service locator to an AutofacServiceLocator.

var builder = new ContainerBuilder();

// Perform registrations and build the container.
var container = builder.Build();

// Set the service locator to an AutofacServiceLocator.
var csl = new AutofacServiceLocator(container);
ServiceLocator.SetLocatorProvider(() => csl);