Ninject

Source
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();

Using an existing kernel

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

DependencyLifecycle Mapping

DependencyLifecycle maps to Ninject object scopes as follows:

DependencyLifecycleNinject object scope
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