Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AspectCore.Extensions.DependencyInjection 中InterceptorCollector 作用域问题 #281

Open
yjqGitHub opened this issue Mar 15, 2022 · 1 comment

Comments

@yjqGitHub
Copy link

您好,我们看代码中发现以下实例生命周期作用域有冲突:
8CD90A40-5829-4115-B1AF-F498907CA037
73341964-9964-471b-B776-AE3191E47837
IPropertyInjectorFactory 接口是Scope作用域,但是InterceptorCollector作用域是Singleton单例,InterceptorCollector中引用了IPropertyInjectorFactory ,也就是在Singleton的实例中引用了Scope,这个设计是不是不合理的?
System.InvalidOperationException: Cannot consume scoped service 'AspectCore.DependencyInjection.IPropertyInjectorFactory' from singleton 'AspectCore.DynamicProxy.IInterceptorCollector'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)

@liuhaoyang
Copy link
Member

感谢指正 。 PropertyInjectorFactory 使用单例其实是没问题的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants