Castle Windsor:启用“优化代码”发布时“没有支持服务的组件”例外

时间:2014-02-24 19:53:19

标签: asp.net-mvc castle-windsor

我使用以下代码注册MVC控制器

public void Install(IWindsorContainer container, IConfigurationStore store)
{
    container.Register(Classes.FromThisAssembly()
                            .BasedOn<IController>()

}

当我发布禁用“优化代码”的代码时,它可以正常工作。但是,如果我发布了“优化代码”,则获得以下异常。

No component for supporting the service Test.TestController was found

在下面标出的行上:

protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
    if (controllerType == null)
    {
        throw new HttpException(404, string.Format("The controller for path '{0}' could not be found.", requestContext.HttpContext.Request.Path));
    }

    return (IController)_kernel.Resolve(controllerType); //exception raised HERE
}

0 个答案:

没有答案