Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading Ninject/Ninject WCF Extensions to the latest version 3.0.0.5

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

like image 928
Thomas Avatar asked Feb 02 '23 05:02

Thomas


1 Answers

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

like image 139
Remo Gloor Avatar answered May 01 '23 16:05

Remo Gloor