I'm looking to register an EasyNetQ's IBus
which implements IDisposable
as a singleton with StructureMap.
The issue is when using nested container, the instance is disposed with the container, thus leaving me with a singleton instance being disposed for every other containers.
For<IBus>()
.Use(c => BusBuilder.CreateMessageBus())
.Singleton();
ContainerScoped
is not an option here as I need that is kept alive during all the application lifespan.
How do I prevent StructureMap from disposing this instance with nested containers ? How do I tell it to dispose the instance only with the root container ?