2010-02-08 40 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。

相關問題