Hopefully this isn't a duplicate question. I've been trying to find a good solution (maybe there just isn't one for .NET Framework console applications) for implementing Autofac without the service locator anti-pattern and still using lifetime scopes to avoid possible leaks.
I read the getting started guide: Autofac Getting Started
And found:
The container itself is a lifetime scope, and you can technically just resolve things right from the container. It is not recommended to resolve from the container directly, however.
I also found multiple answers about implementing Autofac in a console app where it seems the recommended approach to avoid service locator is to make two classes. The static composition root where all dependencies are registered and the container is used to resolve the second Application Runner class.
Generally Accepted Answer on SO
This approach avoids service locator but you resolve all dependencies from the root container which the Autofac docs say you shouldn't do. They say you can avoid this by using one of their Integration Libraries. But none of those are for .NET Framework.
Is there any good way in a .NET Framework console application to avoid service locator but still use child lifetime scopes to manage dependency disposal?