Simple Injector Usage

Component: SimpleInjector Container
NuGet Package NServiceBus.SimpleInjector (2.x)
This is a community run project
Target NServiceBus Version: 6.x

Configuring NServiceBus to use the container

var endpointConfiguration = new EndpointConfiguration("Samples.SimpleInjector");

    registration: components =>
        components.RegisterSingleton(new MyService());

Injecting the dependency in the handler

public class MyHandler :
    MyService myService;

    public MyHandler(MyService myService)
        this.myService = myService;

    public Task Handle(MyMessage message, IMessageHandlerContext context)
        return Task.CompletedTask;

Related Articles

  • Containers
    NServiceBus automatically registers components, handlers, and sagas.
  • Simple Injector
    Configure NServiceBus to use Simple Injector as a container.

Last modified