Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ELMAH MVC 2 - Issue with Castle Windsor

I've just installed ELMAH MVC (v2) into my web application but when I try to view the logs at /elmah I get the following exception

No component for supporting the service Elmah.Mvc.ElmahController was found [ComponentNotFoundException: No component for supporting the service Elmah.Mvc.ElmahController was found] Castle.MicroKernel.DefaultKernel.Resolve(Type service) +140 Castle.Windsor.WindsorContainer.Resolve(Type service) +40 N2.Engine.Castle.WindsorServiceContainer.Resolve(Type type) +40 N2.Engine.ContentEngine.Resolve(Type serviceType) +48

The web site includes the N2 CMS system which in turn uses Castle Windsor.

Any ideas on how I can resolve this?

like image 475
FloatLeft Avatar asked Jul 09 '12 09:07

FloatLeft


1 Answers

I know this already has an accepted answer, and it's not entirely relevant to your question, but for anyone else not using N2 and running into issues with Elmah.MVC+Castle Windsor, you need to register the controllers in the Elmah.MVC assembly with Windsor. I made a simple installer to handle this for me:

public class ElamhInstaller : IWindsorInstaller
{
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container.Register(Classes.FromAssemblyNamed("Elmah.Mvc")
            .BasedOn<IController>()
            .LifestyleTransient());
    }
}

Once I added this Castle seems to be able to find the ElmahController just fine.

like image 52
Tieson T. Avatar answered Oct 16 '22 10:10

Tieson T.