abp 报Autofac.Core.DependencyResolutionException 依赖注入的错

An exception was thrown while activating Castle.Proxies.ProcedureAppServiceProxy.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.ProcedureAppServiceProxy.
---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Castle.Proxies.ProcedureAppServiceProxy' can be invoked with the available services and parameters:
Cannot resolve parameter 'Volo.Abp.Domain.Repositories.IRepository`2[SnAbp.ConstructionBase.Entities.ProcedureRltFile,System.Guid] procedureRltFileRepo' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], Volo.Abp.Domain.Repositories.IRepository`2[SnAbp.ConstructionBase.Entities.Procedure,System.Guid], Volo.Abp.Domain.Repositories.IRepository`2[SnAbp.ConstructionBase.Entities.ProcedureMaterial,System.Guid], Volo.Abp.Domain.Repositories.IRepository`2[SnAbp.ConstructionBase.Entities.ProcedureWorker,System.Guid], Volo.Abp.Domain.Repositories.IRepository`2[SnAbp.ConstructionBase.Entities.ProcedureEquipmentTeam,System.Guid], Volo.Abp.Domain.Repositories.IRepository`2[SnAbp.ConstructionBase.Entities.ProcedureRltFile,System.Guid], Volo.Abp.Guids.IGuidGenerator, Volo.Abp.Domain.Repositories.IRepository`2[SnAbp.Identity.DataDictionary,System.Guid])'.

Autofac.Core.DependencyResolutionException:激活Castle.Proxies.ProcedureAppServiceProxy时引发了异常。
---> Autofac.Core.DependencyResolutionException:不能使用可用服务和参数调用类型为'Castle.Proxies.ProcedureAppServiceProxy'的'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'发现的构造函数:
无法解析构造函数'Void .ctor(Castle.DynamicProxy.IInterceptor [],Volo.Abp.Domain的构造函

 

说某个仓储  IRepository 没有 构造函数 参数  

 

这个时候 检查下 IDbContext 和 DbContext  ,把 对应 缺失 的 dbSet  补上就可以了 

 

2021年6月17号更新  记住一定要把 dbset<T> 写在构造函数 上 面 !, rider 按 alt+enter 生成 的 实现代码 把他弄到 构造函数 下面了 ,导致 即使 有 dbset ,还是报这个错 ! 

 

在更新 ,还是报这个错的话 在 对应的 ef core module .cs 里面 加上 这个 

 

再次更新 ,如果是引用别的模块 的 IService 报 这个错的话,就 是 要在 

 

 

再再再更新 

如果 appService 继承了 CrudService ,然后 引用 别的模块 的 IService 依赖注入  也可能报这个错误 

这个时候 要在 对应 的模块 里面  把 IService 注册一下 

 

posted @ 2021-05-28 20:45  ifnk  阅读(9309)  评论(2编辑  收藏  举报