简体   繁体   English

如何使用ABP在我的所有临时依赖项中拥有PerWebRequest Lifestyle?

[英]How to have a PerWebRequest Lifestyle in all my transient dependencies using ABP?

We're facing an issue in terms of performance in a .NET Framework 4.6.1 application that uses ABP 4.8.1. 就使用ABP 4.8.1的.NET Framework 4.6.1应用程序的性能而言,我们面临一个问题。 The detected issue is related to a continuous use of the dependency injector resolver with transient dependencies. 检测到的问题与具有临时依赖关系的依赖关系注入程序解析器的持续使用有关。

We were trying to change the "Lifestyle" from Transient to PerWebRequest, using Castle Windsor (This is the default package that ABP uses) but if we do this we keep getting this exception: 我们试图使用Castle Windsor(这是ABP使用的默认软件包)将“生活方式”从Transient更改为PerWebRequest(这是ABP使用的默认程序包),但是如果这样做,我们将不断收到此异常:

Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule”? 您似乎忘记了注册http模块Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule”?

Of course we added the necessary lines, as mentioned in: https://stackoverflow.com/a/34920667/12042620 当然,我们添加了必要的行,如在https://stackoverflow.com/a/34920667/12042620中所述

The exception was thrown when we tried with a proof of concept like this: 当我们尝试使用这样的概念证明时,抛出了异常:

public class MyModule : AbpModule
{
        public override void PreInitialize()
        {
            Database.SetInitializer(new CreateDatabaseIfNotExists<MyDbContext>());
            Configuration.DefaultNameOrConnectionString = "Default";
        }

        public override void Initialize()
        {
            IocManager.IocContainer.Register(
                Component
                    .For<MyDbContext>()
                    .LifestylePerWebRequest()
                );
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
        }
}

I was trying to find some other possible solutions but all of them are related to .NET Core (they use 'Scoped' instead of this). 我试图找到其他可能的解决方案,但所有这些解决方案都与.NET Core有关(它们使用'Scoped'代替了它)。 Is there any way to implement this Lifestyle for all our dependencies while using ABP? 在使用ABP时,有什么方法可以为我们所有的依赖关系实现这种生活方式吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的上下文上等待第二次操作,然后先完成针对该上下文的生活方式PerWebRequest和对其的异步调用 - how wait second operation on my context before first completes with lifestyle PerWebRequest for the context and asynchronous calls to it 如何使用城堡温莎在诸如PerWebRequest之类的范围内的生活方式中注册服务? - How to register services in scoped lifestyle behaving like PerWebRequest using castle windsor? PerWebRequest生活方式的工厂方法 - Factory Methods with PerWebRequest lifestyle Singleton中具有生活方式PerWebRequest的对象 - object with lifestyle PerWebRequest in Singleton 如何在OWIN中使用Castle Windsor的PerWebRequest生活方式 - How to use Castle Windsor's PerWebRequest lifestyle with OWIN CastleWindsor LifeStyle.PerWebRequest的行为与singleton相似 - CastleWindsor LifeStyle.PerWebRequest behaves like singleton 温莎城堡FirstInterface()。Configure(c =&gt; c.LifeStyle.PerWebRequest) - Castle Windsor FirstInterface().Configure(c=> c.LifeStyle.PerWebRequest) 在具有PerWebRequest生活方式的对象中释放WcfService代理依赖关系的策略 - Release policy for WcfService proxy dependency in object having PerWebRequest lifestyle 温莎城堡:将组件的生活方式设置为瞬态后,我的代码将无法工作 - Castle Windsor: My code won't work after setting component lifestyle to transient 临时生活方式组件的温莎循环依赖 - Windsor circular dependency of a transient-lifestyle component
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM