Ninject in .NET Core Ninject in .NET Core asp.net asp.net

Ninject in .NET Core


Ninject 3.3.0 was released September 26th 2017 and now targets .NET Standard 2.0 and thus also runs on .NET Core 2.0.

From the course of things (see issues/discussions on GitHub) it seems likely that some of the changes in the 4.0-beta will be reverted. I would not expected a 4.0 final shortly. Hence I would advise to go with the current version 3 release.


Just wanted to add; while both of the previous answers are correct in that ASP.Net core does provide built in dependency injection, it is NOT sufficient for more advanced scenarios. As it does not support a whole host of features that Ninject, AutoFac, Unity, or StructureMap supports.

At present, the only DI libraries that I am aware of that fully supports .net core are AutoFac and now Unity as well. It is very simple to add this in. The only thing you need to do to replace the built in DI is as follows. This example is for AutoFac but its almost identical for Unity it looks like.

First, replace the void on ConfigureServices in startup.cs with an IServiceProvider (dependency from AutoFac) like so:

public IServiceProvider ConfigureServices(IServiceCollection services)

Then create a container builder, build and resolve an IServiceProvider from ConfigureServices:

var builder = new ContainerBuilder();builder.Populate(services);var container = builder.Build();return container.Resolve<IServiceProvider>();

I have a wrapper around the this second part that allows you to dynamically load and build different configurations using AutoFac modules, that I might be convinced to upload to GitHub or something if there is any interest.


Ninject does not support .NET Core. You can check it's website to be sure if there is no version that supports it.

ASP.NET Core has its own Dependency Injection container build in. See here.