无法解析serviceType [控制器名称]

时间:2009-12-17 13:13:03

标签: c# asp.net-mvc ioc-container turbine

当尝试重构现有的asp.net-mvc应用程序以将Turbine用作IoC时,我得到以下结果:

MvcTurbine.ComponentModel.ServiceResolutionException 
Could not resolve serviceType 'CommonProject.Web.Shared.Controllers.SearchController' 
Source Object: at MvcTurbine.Unity.UnityServiceLocator.Resolve[T](Type type)

我的SearchController的(唯一)ctor看起来像这样

public SearchController(ISearchService searchService):base(new SearchViewData())
{
    this.searchService = searchService;
}

我的注册看起来像这样

public class SearchServiceRegistration: IServiceRegistration
{
    public void Register(IServiceLocator locator)
    {
        locator.Register<ISearchService>(typeof(LuceneSearchService));
    }
}

更新

我找到了它(它有点愚蠢)

locator.Register<ISearchService>(typeof(LuceneSearchService));

应该是

locator.Register<ISearchService,LuceneSearchService>();

不知道第一种语法应该做什么。

1 个答案:

答案 0 :(得分:0)

您是否错过了SearchController的注册?