在netcore 中 autofac 6.0 版本使用 aop

2020-02-15 12:30发布

问题:

如果是5.0,是没有问题的,
但是如果升级到 autofac 6.0,
<ItemGroup>

<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="4.5.0" />

</ItemGroup>

则会报错:

An unhandled exception occurred while processing the request.
ProxyGenerationException: This is a DynamicProxy2 error: Target type for the proxy implements Castle.DynamicProxy.IProxyTargetAccessor which is a DynamicProxy infrastructure interface and you should never implement it yourself. Are you trying to proxy an existing proxy?

希望有用到 autofac 6.0+的,并且配置aop的小伙伴,不吝赐教

回答1:

参考 Unable to hook up interceptor on classes/interfaces in asp.net core 3.1 application