Last post Jul 26, 2013 05:18 AM by dscher
Oct 06, 2011 08:45 AM|mrdavid|LINK
Has any got any idea of what I'm doing wrong here? I'm trying to inject a class called ProgrammeService (which itself takes an instance of IPlatrformRespository in its construtor) into my HomeController using asp.net MVC 3 but I get a 'No component for supporting
the service Web.Controllers.HomeController was found. First I overwrote the defaultcontrollerfactory in MVC wiith the below code:
/// see http://docs.castleproject.org/Windsor.Windsor-tutorial-ASP-NET-MVC-3-application-To-be-Seen.ashx
public class WindsorControllerFactory : DefaultControllerFactory
private readonly IWindsorContainer _container;
public WindsorControllerFactory(IWindsorContainer container)
_container = container;
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
if (controllerType == null) return base.GetControllerInstance(requestContext, controllerType);
var controller = (Controller)_container.Resolve(controllerType);
public override void ReleaseController(IController controller)
and then I create a windsorcontainer
public class BootStrapper
public static IWindsorContainer Container;
public static void ConfigureDependencies()
Container = new WindsorContainer();
Container.AddComponent("HomeController", typeof(IPlatformRepository), typeof(PlatformRespository));
and call configureDependencies from my global.asax file. What am I missing. I know with structuremap I don't have to explicity mention ProgrammeService itself as it is dependent on IPlatformRespositroy and that is there, but if you've any ideas please advise.
I'm also wondering about the whereabouts of the 'FromAssembly' helper class. Some tutorials mention it but I can never get it to resolve, no matter what namespaces I include.
Thanks in advance.
Oct 13, 2011 06:13 AM|Juntao Zh - MSFT|LINK
I think it's worth to check the call stack of the exception and find out which function is the excption from. it doesn't look like a MVC error message.
Jul 26, 2013 05:18 AM|dscher|LINK
You're registering the controller as "HomeController". This is not the name. Try this registration instead:
.Configure(x => x.Named(x.Implementation.FullName)));