Hosting NServiceBus comes down to configuring and then starting an instance of a bus. There are two ways to do this, either as an NServiceBus-hosted endpoint, or as a self-hosted endpoint. In both cases, the focus is on setting up your desired settings via a BusConfiguration
object.
An NServiceBus-hosted endpoint is a process that is run by executing the NServiceBus.Host.exe
process, which is a part of the NServiceBus.Host
NuGet package. We already know that a .NET executable is just a DLL that can be directly executed, and can be referenced just like a normal DLL. The host's NuGet package automates the process of creating a reference to the executable, and then sets the Debug tab's Start Action to run the host executable. You can see this for yourself by opening a hosted endpoint's properties page and inspecting the settings on the Debug tab.
When the host process starts up, it scans all the assemblies in the same directory, looking for a class that...