Scope was not available. Did you forget to call container.BeginScope()?

我是研究僧i 提交于 2019-12-24 07:16:18

问题


Hello I want to using castle windosr in .net core and I have get bellow error in .net core:

Scope was not available. Did you forget to call container.BeginScope()?

my code is :

         public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        var container = new WindsorContainer();
        //container.BeginScope();
        Bootstrapper.WireUp(container);
        FrameworkBootstrapper.WireUp(container);
        var configureServices = WindsorRegistrationHelper.CreateServiceProvider(container, services);
        return configureServices;
    }

I added the error image .

in your option if i add container.BeginScope(); after var container = new WindsorContainer(); Is it the right way? Is there any problem? WindsorRegistrationHelper is a package between .net core built in ioc and castle you can see on below link: https://github.com/volosoft/castle-windsor-ms-adapter

来源:https://stackoverflow.com/questions/51853830/scope-was-not-available-did-you-forget-to-call-container-beginscope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!