having a fresh setup of asp.net core 5 app gives me the problem of not beeing able to set a per web request scope as SimpleInjector tells me to setup a scoped default lifestyle which is in an old package. This article from simpleinjector help says there is a integration package but cannot find any way to setup correctly without getting the excpetion when using the request lifetime scope, see code below.
public static class ContainerManager
{
private static readonly Lazy<Container> _container = new Lazy<Container>(ConfigureServices);
private static Container ConfigureServices()
{
var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name.StartsWith("Nordmann.Timetables")).ToList();
var container = new Container();
//General
var lifeStyle = Lifestyle.CreateHybrid(Lifestyle.Scoped, Lifestyle.Transient);
DomainConfig.Register(new DomainEventStoreProvider(container));
container.Register<IDomainEventStore, InMemoryDomainEventStore>();
container.Register<IEventDispatcher, Dispatcher>(Lifestyle.Scoped);
container.Collection.Register(typeof(IEventHandler<>), assemblies);
container.Register(typeof(IQueryHandler<,>), assemblies);
//CM
container.Register<INordmannUnitOfWork, NordmannUnitOfWork>(Lifestyle.Scoped); //WebRequest
container.Register<UserApplicationService>(Lifestyle.Transient);
container.Verify();
return container;
}
public static Container Instance { get => _container.Value; }
}