无法使用ServiceLocator找到IValidator

时间:2010-02-08 22:18:42

标签: c# nhibernate s#arp-architecture

使用sharparchitecture并尝试在域对象上调用IValidatable.IsValid时出现以下错误。

如何针对公共服务定位器注册NHibernate验证器的实例?

我见过以下单元测试:

http://code.google.com/p/sharp-architecture/source/browse/trunk/src/SharpArch/SharpArch.Tests/SharpArch.Core/SafeServiceLocatorTests.cs?spec=svn385&r=385

对此有任何帮助真的很感激。

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

1 个答案:

答案 0 :(得分:1)

事实证明,当我意识到我没有在我的DI Conatiner上注册IValidator时,我有一个耳光的时刻。

相关问题