Upgrading Ninject/Ninject WCF Extensions to the latest version 3.0.0.5
Asked Answered
P

1

9

I am currently using Ninject (2.2.1.4) and Ninject.Extensions.Wcf (2.2.0.4) with my WCF service. I would like to upgrade to Ninject (3.0.0.15) and Ninject.Extensions.Wcf (3.0.0.5) and it doesn't look like I can use my current approach anymore. Can anyone point me to some samples or posts on how to get the latest version of Ninject working with a WCF project.

My current approach:

I wrote a module:

public class NinjectDependencyResolver : NinjectModule
{
    public override void Load()
    {
        // Declare bindings
    }
}

I added the Factory Attribute to my .svc file

Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory"

I added a Global.asax to the WCF project

public class Global : NinjectWcfApplication
{
    protected override IKernel CreateKernel()
    {
        return new StandardKernel(new NinjectDependencyResolver());
    }
}

Now I can modify the default constructor in my service and use constructor injection.

Any pointers on how I could upgrade are appreciated.

Thanks

Procrastinate answered 30/4, 2012 at 21:26 Comment(0)
C
12

Add Ninject.Web.Common and derive from NinjectHttpApplication or use the App_Start file that comes with the NuGet package.

Clute answered 30/4, 2012 at 23:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.