Instead of this:
Configure
.With()
.StructureMapBuilder(ObjectFactory.Container)
Use the default container:
Configure
.With()
.DefaultBuilder()
Because you're no longer passing ObjectFactory.Container
through to NServiceBus, you'll need to tell StructureMap how to fulfill IBus
as a dependency for, e.g. your MVC controllers:
x.For<NServiceBus.IBus>()
.Use(() => Configure
.Instance
.CreateBus()
.Start(() => Configure.Instance.ForInstallationOn<Windows>().Install())
);
If you have something that NServiceBus needs to create, e.g. something that implements IMutateOutgoingMessages
and your message mutator has dependencies, then you'll have to tell NServiceBus how to resolve those dependencies:
Configure
.Instance
.Configurer
.ConfigureComponent(
() => new MessageMutator(new MessageMutatorDependency()),
DependencyLifecycle.InstancePerCall
);