使用sharparchitecture并尝试在域对象上调用IValidatable.IsValid时出现以下错误。
如何针对公共服务定位器注册NHibernate验证器的实例?
我见过以下单元测试:
对此有任何帮助真的很感激。
The needed dependency of type IValidator could not be located with the ServiceLocator. You'll need to register it with the Common Service Locator (CSL) via your IoC's CSL adapter.
at SharpArch.Core.SafeServiceLocator`1.GetService() in C:\MyStuff\Projects\SharpArchGitHub\src\SharpArch\SharpArch.Core\SafeServiceLocator.cs:line 29
at SharpArch.Core.DomainModel.ValidatableObject.IsValid() in C:\MyStuff\Projects\SharpArchGitHub\src\SharpArch\SharpArch.Core\DomainModel\ValidatableObject .cs:line 11
at Tuhdoo.Common.Validation.ValidatableExtensions.Validate(IValidatable entity) in D:\Repository\Tuhdoo\src\Tuhdoo.Common\Validation\ValidatableExtensions.cs:line 26
答案 0 :(得分:1)
事实证明,当我意识到我没有在我的DI Conatiner上注册IValidator时,我有一个耳光的时刻。