I'm migrating from ASP.NET Core 2.2 to ASP.NET Core 8, and I have this problem.
To keep the code changes as minimum as possible, I'm using WebHost.CreateDefaultBuilder() passing a Startup class.
In this, I'm using a ConfigureServices that returns an AutofacServiceProvider with a ILifetimeScope object. I use the classic AddMvc/UseMvc (with the endpoints disabled). I've removed all the old NuGet packages and created SDK style .csproj with the ".web" suffix or added the <FrameworkReference Include="Microsoft.AspNetCore.App" />.
Trying to test it, I get an error when in Microsoft.AspNetCore.Mvc.Routing is called the GetTreeRouter() function, I get:
Autofac.Core.Activators.Reflection.NoConstructorsFoundException : No constructors on type 'Microsoft.AspNetCore.Routing.Tree.TreeRouteBuilder' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.
In the code, the TreeRouteBuilder seems internal, so it's normal the DI is not capable of finding the constructor. I've forgotten to update something essential to work?
EDIT:
I've changed the AddMvc and UseMvc with more modern AddControllersWithViews and UseRouting and UseEndpoints, I get this exception
Autofac.Core.DependencyResolutionException : An exception was thrown while activating Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder -> Microsoft.AspNetCore.Routing.MatcherPolicy[] -> Microsoft.AspNetCore.Mvc.Routing.DynamicControllerEndpointMatcherPolicy. Data: ActivatorChain: Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder -> Microsoft.AspNetCore.Routing.MatcherPolicy[] -> Microsoft.AspNetCore.Mvc.Routing.DynamicControllerEndpointMatcherPolicy ----> Autofac.Core.Activators.Reflection.NoConstructorsFoundException : No constructors on type 'Microsoft.AspNetCore.Routing.Matching.EndpointMetadataComparer' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.
Also this constructor is an internal one. I'm start to think that I'm having something wrong that doesn't register the ASP.NET Core to the Autofac container. I return the IServicesProvider in ConfigureServices, need to check if this is still possible or not possible in ASP.NET Core 8