I believe I’ve made a foolish assumption that the IBus object will be loaded throughout an application and it’s referenced assemblies.
For instance if I was to do the following inside of a referenced assembly:
public IBus Bus {get;set;}
Am I correct in saying that this object will only be loaded on classes that implement an NServiceBus class such as IHandleMessages and IWantToBeLoadedAtStartup?
Any help or clarification on the specifics would be great.
Thanks
What you’re referring to is Dependency Injection. NServiceBus will inject an
IBusinstance only into objects which are managed by NServiceBus.For example, NServiceBus creates an instance of classes implementing
IHandleMessageswhen a transport message arrives and injects an instance of the bus client using the Dependency Injection container.You can extend the dependency injection mechanism as shown here.