相关疑难解决方法(0)

在 ASP.NET Core 3.0 中配置 Autofac 的推荐方法

在 ASP.NET Core 2.0 中,我使用类上的ConfigureServices方法Startup来连接 Autofac,包装现有的services注册并添加额外的一次。

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    // Standard service registrations (ex: services.AddMvc())
    // ...

    // Autofac
    var builder = new ContainerBuilder();
    builder.Populate(services); // wrap service registrations
    builder.RegisterModule<MyModule>(); // add extra registrations

    this.ApplicationContainer = builder.Build();
    return new AutofacServiceProvider(this.ApplicationContainer);
}
Run Code Online (Sandbox Code Playgroud)

由于ConfigureService方法void在 ASP.NET Core 3.0 中并且不再支持返回参数IServiceProvider,我该如何连接 Autofac?

c# autofac asp.net-core-3.0

5
推荐指数
1
解决办法
3906
查看次数

标签 统计

asp.net-core-3.0 ×1

autofac ×1

c# ×1