Search code examples
light-inject

Implement LightInject WCF into a WCF web Service


I am trying to implement LightInject into my WCF service.

I have the LightInject.Wcf class file from GitHub but i have no clue on how to use it in my service.

Please help


Solution

  • I just run into the same problem. I had already noticed the post you are referring to, but i assumed there must be an easier way. By inspecting the code i found an alternative:

    Make sure you get the latest version of LightInject.Web and LightInject.Wcf. Just as a regular MVC application you can setup things in the global.asax:

    protected void Application_Start(object sender, EventArgs e)
    {
            var container = new ServiceContainer();           
            container.Register<ILogger, Log4netLogger>();
            container.EnableWcf();
    
    }
    

    After this, configure the services as you would normally do without LightInject.