• ABP 依赖注入不了 Can't create component 'xxx.xxx.xxx' as it has dependencies to be satisfied


    原文:
    https://www.cnblogs.com/senyier/p/7298847.html



    报错:

    An unhandled exception occurred while processing the request.
    HandlerException: Can't create component 'BIMMP.OAMS.OAContractSealAppService' as it has dependencies to be satisfied.
    
    'BIMMP.OAMS.OAContractSealAppService' is waiting for the following dependencies:
    - Service 'Abp.Domain.Repositories.IRepository`2[[BIMMP.OAMS.OAContractSeal, BIMMP.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Int32, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
    Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
    



    原因:

    BIMMPDbContext 中忘了加这句 public virtual DbSet<OAContractSeal> OAContractSeals { get; set; }

    总结:

    数据库里面也有那张表,估计是谁提交代码的时候,把那句代码给冲掉了

    全部代码:

    IOAContractSealAppService.cs

    namespace BIMMP.OAMS
    {
        public interface IOAContractSealAppService : IApplicationService
        {
           
        }
    }
    

    OAContractSealAppService.cs

    namespace BIMMP.OAMS
    {
        [AbpAuthorize]
        public class OAContractSealAppService : BIMMPAppServiceBase, IOAContractSealAppService
        {
            private readonly IRepository<OAContractSeal, int> _oAContractSealRepository;
    
            public OAContractSealAppService(
            IRepository<OAContractSeal, int> oAContractSealRepository)
            {
                _oAContractSealRepository = oAContractSealRepository;
            }
        }
    }
    

    BIMMPDbContext.cs

    namespace BIMMP.EntityFrameworkCore
    {
        public class BIMMPDbContext : AbpZeroDbContext<Tenant, Role, User, BIMMPDbContext>
        {
            public virtual DbSet<OAContractSeal> OAContractSeals { get; set; }
            public BIMMPDbContext(DbContextOptions<BIMMPDbContext> options)
                : base(options)
            {
            }
        }
    }
    

    OAContractSeal.cs

    namespace BIMMP.OAMS
    {
        [Table("OAContractSeal")]
        public class OAContractSeal : AuditedEntity<int>
        {
            [Required]
            [MaxLength(50)]
            public string ContractName { get; set; }
        }
    }
    
  • 相关阅读:
    mysql中IN和EXITS效率
    POJ 3301 Texas Trip
    Swift项目兼容Objective-C问题汇总
    使用linq对字符串1,2,3,4,5,6,7,8,9,10求和
    CodeForces 228D. Zigzag(线段树暴力)
    代理模式
    Oracle成长点点滴滴(3)— 权限管理
    数据结构基础 之 图 的 邻接矩阵实现与邻接表实现
    android CoordinatorLayout使用
    Android开发之蓝牙(Bluetooth)操作(二)--修改本机蓝牙设备的可见性,并扫描周围可用的蓝牙设备
  • 原文地址:https://www.cnblogs.com/guxingy/p/13559360.html
Copyright © 2020-2023  润新知