Ninject

Project Hosting
NuGet NServiceBus.Ninject (3.x)
Target NServiceBus Version: 3.x
Standard support for version 3.x of NServiceBus has expired. For more information see our Support Policy.

NServiceBus can be configured to use Ninject as a dependency injection container.

Default Usage

configure.NinjectBuilder();

Existing Container Instance

var kernel = new StandardKernel();
kernel.Bind<MyService>()
    .ToConstant(new MyService());
configure.NinjectBuilder(kernel);

DependencyLifecycle Mapping

The DependencyLifecycle maps to Ninject in the following way.

DependencyLifecycleNinject Equivalent
InstancePerCallTransient
InstancePerUnitOfWorkSingleton within a Named Scope per Unit of Work
SingleInstanceSingleton

Related Articles

  • Child Containers
    Child containers are a snapshot of the main container; transient instances are treated as as singletons in the child container.

Last modified