Search code examples
autofac

how to use ValidateScopes in autofac?


if i use default ioc in asp.net core,i can use this option :

WebHost.CreateDefaultBuilder(args)
    .UseDefaultServiceProvider((context, options) => {
        options.ValidateScopes = true;
    })

but how to use this config in autofac? I don't see any relevant documentation on the github homepage

When ValidateScopes is set to true, the default service provider performs checks to verify that: Scoped services aren't directly or indirectly resolved from the root service provider. Scoped services aren't directly or indirectly injected into singletons.


Solution

  • ValidateScopes - as with UseDefaultServiceProvider - are both not Autofac. There is no equivalent in Autofac. There is documentation about caprice dependencies but nothing to prevent you from doing it.