Ninject Not creating the Ninjectwebcommon class

Asked

Viewed 347 times

1

I’m installing the package of ninject, but the class is not created Ninjectwebcommon automatically in the folder App_start.

Does anyone have any solution? I am installing the version Ninject.MVC5.

  • Tries: Update-Package -reinstall -ProjectName NomeDoProjeto

  • Nothing... No file appears...

2 answers

1

The latest version of Ninject.MVC5. Changed and no longer create the NinjectWebCommon in the App_Start, instead you have to change the file Global.asax.cs inheriting the 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);
    }
}

Take the example here and here.

0

In version 3.3.0 of Ninject I had this problem:

Install-Package Ninject.Web.Webapi.Webhost -Version 3.3.1

Install-Package Webactivatorex -Version 2.2.0

In my case the class Ninjectwebcommon.Cs has already appeared in App_start.

If it doesn’t appear you can create a Ninjectwebcommon class in App_start and continue

Browser other questions tagged

You are not signed in. Login or sign up in order to post.