0

I am getting an exception when initializing Castle Windsor in an ASP.NET MVC3 application. Here is the exception that I am getting:

Microsoft.Practices.ServiceLocation.ActivationException was unhandled by user code Message=Activation error occured while trying to get instance of type IController, key "favicon.ico"
Source=Microsoft.Practices.ServiceLocation StackTrace: at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 57 at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 103 at AN.Core.Windsor.Web.WindsorControllerFactory.CreateController(RequestContext requestContext, String controllerName) InnerException: System.MissingMethodException Message=Method not found: 'Castle.Core.Internal.GraphNode[] Castle.Core.Internal.GraphNode.get_Dependers()'. Source=AN.Core.Windsor.Web StackTrace: at AN.Core.Windsor.Web.WindsorServiceLocator.DoGetInstance(Type serviceType, String key) at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 49 InnerException:

Here is my initialization code in my global.asax:

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);

    BootstrapWindsorContainer();
}

private static void BootstrapWindsorContainer()
{
    _container = new WindsorContainer()
        .Install(FromAssembly.InThisApplication());             

    ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(_container));

    var controllerFactory = new WindsorControllerFactory();
    ControllerBuilder.Current.SetControllerFactory(controllerFactory);
}
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Greg Finzer
  • 6,714
  • 21
  • 80
  • 125
  • Is it just when initializing? It looks like a reasonable error since the controller for the "favicon.ico" file will never be found. – Jace Rhea Jan 09 '14 at 21:26
  • It is weird. If I comment out BootstrapWindsorContainer() then the page loads fine. – Greg Finzer Jan 09 '14 at 21:29
  • Do the answers in this question help - http://stackoverflow.com/questions/1434900/why-is-my-castle-windsor-controller-factorys-getcontrollerinstance-being-call – Ian Nelson Jan 09 '14 at 21:32

1 Answers1

2

You need to add a favicon.ico to the collection of routes to ignore.

For example:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("favicon.ico");
}
Makotosan
  • 1,149
  • 2
  • 12
  • 20