调用ABP接口时出现以下异常
2022-06-24 11:41:58.983 +08:00 [ERR] An exception was thrown while activating Castle.Proxies.RedeemSuccessCodeServiceProxy.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.RedeemSuccessCodeServiceProxy.
---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Castle.Proxies.RedeemSuccessCodeServiceProxy' can be invoked with the available services and parameters:
Cannot resolve parameter 'CamBook.Domain.UserRecord.RedeemCode.IRedeemSuccessRepository redeemSuccessRepository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], CamBook.Domain.UserRecord.RedeemCode.IRedeemSuccessRepository)'.
at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
具体服务类如下:
构造函数也运行不到,直接报上面错误;
网上说没有定义DBSet,实际上已经定义了DBSet
IRedeemSuccessRepository的定义如下:
也有对应的实现类,如下:
对应的实体类定义如下:
有没有注册 IRedeemSuccessRepository
的实现 EfCoreReSuccessRepository
?
EfCoreReSucessRepsitory已经实现这个接口了,我定义的其他服务也是用对应的类定义,反而可以调用。
@tuohaibei: EfCoreReSucessRepsitory 怎么注册到依赖注入容器的?
@dudu: 应该是abp vnext自动实现的,直接用的UseAutoFac()
@dudu: 还是不好
已经解决了,接口和实现类要有特定的命名规则,天坑啊。
– tuohaibei 2年前参考这里:
https://blog.csdn.net/sd7o95o/article/details/112597540