2010-02-08 33 views
0

使用锐构架时出现以下错误,并尝试在域对象上调用IValidatable.IsValid。无法通过ServiceLocator找到IValidator

我该如何注册一个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

您使用的是什么IoC容器? – 2010-02-09 02:23:59

回答

1

事实证明,这是很明显我一巴掌头那一刻,我意识到我没有注册我的DI Conatiner的IValidator。

相关问题