您好,我想在.net核心中使用Castle Windosr,并且在.net核心中遇到波纹管错误:
范围不可用。你忘了打电话吗 container.BeginScope()?
我的代码是:
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;
}
如果我在container.BeginScope();
之后添加var container = new WindsorContainer();
,则可以选择吗?这是正确的方法吗?有什么问题吗?
WindsorRegistrationHelper是内置在ioc中的.net核心和Castle之间的软件包
您可以在以下链接上看到:
https://github.com/volosoft/castle-windsor-ms-adapter