Ninject

Project Hosting
NuGet Package 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 for dependency injection.

Default Usage

configure.NinjectBuilder();

Existing 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

Samples

Related Articles

  • Child lifetime
    Child lifetimes are a snapshot of the main instance; transient instances are treated as as singletons in the child lifetime.

Last modified