简体   繁体   English

Unity Resolve 中的堆栈溢出异常

[英]Stack Overflow Exception in Unity Resolve

When i'm going resolve type from unity container StackOverflowException occurs in:当我要从统一容器中解析类型时StackOverflowException发生在:

   public class UserValidator : Validator<User>
   {
        readonly IBaseService<User> _service;
        public UserValidator()
        {
            _service = ApplicationResolver.Instance.Resolve<IBaseService<User>>();
            RuleFor(user => user.Email).EmailAddress();
        }

    }

and BaseService :BaseService

  public BaseService(IBaseRepository<T> repository, IValidator<T> validator)
  {
     Repository = repository;
     Validator = validator;
  }

and Register :Register

container.RegisterType<IValidator<User>, UserValidator>();

should I change the pattern?我应该改变模式吗?

I have BaseService depending on Validator and Validator depending on BaseService .我有BaseService depending on ValidatorValidator depending on BaseService

Repository to use store/retrieve an entity from the data store. Repository用于从数据存储中存储/检索实体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM