AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/nservicebus/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

NServiceBus.Extensions.Hosting Upgrade Version 4 to 5

NServiceBus 10.2 introduces built-in support for hosting endpoints in .NET Generic Host applications via IServiceCollection.AddNServiceBusEndpoint. This makes the NServiceBus.Extensions.Hosting package's UseNServiceBus extension methods unnecessary.

UseNServiceBus is deprecated

The UseNServiceBus extension methods on HostApplicationBuilder and IHostBuilder have been deprecated. Replace calls to UseNServiceBus with AddNServiceBusEndpoint on the host's service collection, then remove the NServiceBus.Extensions.Hosting package reference.

HostApplicationBuilder

Replace:

var builder = Host.CreateApplicationBuilder();

builder.UseNServiceBus(endpointConfiguration);

var host = builder.Build();

with:

var builder = Host.CreateApplicationBuilder();

builder.Services.AddNServiceBusEndpoint(endpointConfiguration);

var host = builder.Build();

IHostBuilder

Replace:

var host = Host.CreateDefaultBuilder()
    .UseNServiceBus(context =>
    {
        var endpointConfiguration = new EndpointConfiguration("MyEndpoint");
        return endpointConfiguration;
    })
    .Build();

with:

var builder = Host.CreateApplicationBuilder();

var endpointConfiguration = new EndpointConfiguration("MyEndpoint");

builder.Services.AddNServiceBusEndpoint(endpointConfiguration);

var host = builder.Build();

Remove the package

After replacing UseNServiceBus with AddNServiceBusEndpoint, remove the NServiceBus.Extensions.Hosting package reference from the project. The AddNServiceBusEndpoint method is provided by the core NServiceBus package starting with version 10.2.