title: 'ConfigureServices returning an System.IServiceProvider isn't supported.' in .NET Core 3.1 using Autofac
body: <p>I want to use autofac injection instead of default .net core solution.</p>
  <p>Here is my startup file :</p>
  <pre>public IServiceProvider ConfigureServices(IServiceCollection services)
  {
      services.AddMvc(option =&gt; option.EnableEndpointRouting = false) ;
             
  
      var cb = new ContainerBuilder();
      cb.RegisterModule&lt;mydependecymodule&gt;();
      cb.Populate(services);
      var container = cb.Build();
  
      return new AutofacServiceProvider(container);
  }
  
  
  // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)                           
  {
      app.UseDeveloperExceptionPage();
      app.UseStatusCodePages();
      app.UseStaticFiles();
           
      app.UseMvc(routes=&gt;routes.MapRoute(&quot;default&quot;,&quot;/{controller=home}/{action=index}&quot;));
  }
  
  </pre>
  <p>And here is my program.cs</p>
  <pre>public static void Main(string[] args)
  {
      CreateHostBuilder(args).Build().Run();
  }
      
  public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
      Host.CreateDefaultBuilder(args)
      .ConfigureWebHostDefaults(webBuilder =&gt;
      {
          webBuilder.UseStartup&lt;Startup&gt;();
      }).UseServiceProviderFactory(new AutofacServiceProviderFactory());
  
  </pre>
  <p>But when I run my application I get this error in my main method:</p>
  <p><code>System.NotSupportedException: 'ConfigureServices returning an System.IServiceProvider isn't supported.'</code></p>