2

I know in ASP.NET Core you can use GetAutofacRoot:

public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
    // If, for some reason, you need a reference to the built container, you
    // can use the convenience extension method GetAutofacRoot.
    this.AutofacContainer = app.ApplicationServices.GetAutofacRoot();
}

...but this doesn't seem viable when using the Generic Host. I'm trying to register a ServiceLocator:

// 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);
Ismael
  • 361
  • 3
  • 9

0 Answers0