Ninject Not creating the NinjectWebCommon class

1

I'm installing the ninject package , but the NinjectWebCommon class is not automatically created in the App_Start folder.

Does anyone have a solution? I'm installing the Ninject.MVC5 version.

    
asked by anonymous 29.01.2018 / 16:43

1 answer

1

The latest version of Ninject.MVC5. Changed and no longer create NinjectWebCommon in App_Start , instead you have to change the Global.asax.cs file by inheriting NinjectHttpApplication .

public class MvcApplication : NinjectHttpApplication
{
    protected override void OnApplicationStarted()
    {
        base.OnApplicationStarted();

        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
        AutoMapperConfig.RegisterMappings();
    }
    protected override IKernel CreateKernel()
    {
        var modules = new NinjectModule[] { new ModulosNinject() };
        return new StandardKernel(modules);
    }
}

See example here and here .

    
31.01.2018 / 13:11