0

I'm trying to setup NSB in a .NET Core Web Api project to send commands to a .NET Core Endpoint project containing handlers to receive messages. Code so far to register NSB:

     public void ConfigureServices(IServiceCollection services)
        {
            ......
            ......
            //services.AddNServiceBus(endpointConfiguration);
            var endpoint = Endpoint.Start(SetupEndpointConfiguration()).GetAwaiter().GetResult();
            services.AddSingleton(endpoint);
        }

According to NSB docs ( https://docs.particular.net/samples/dependency-injection/aspnetcore/ ), using built in DI of .net core ( 3.1 for me), we should be able to call .AddNServiceBus() on the services object. However, I am unable to do so since VS cannot resolve the method. I have the following libraries installed:

    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Hosting;
    using Microsoft.OpenApi.Models;
    using NServiceBus;
    using Serilog;

What I've tried: Made an endpoint using Endpoint.Start() and registered it using addSingleton() as shown in the first code block. But not satisfied since the docs should let me use the AddNServiceBus() to register NSB within ConfigureServices().

Why is .AddNServiceBus() not resolvable, despite having NSB installed?

1 Answers1

0

I think you're missing a using statement:

using NServiceBus.Extensions.DependencyInjection;

You can verify you have the correct ones by clicking "COPY USINGS" above the relevant code snippet in the sample you referenced.

Kyle Baley
  • 580
  • 1
  • 5
  • 16
  • That particular one does not exist when I browse through nuget manager, although you are right that they have that in the docs. Is this the [one](https://github.com/twenzel/NServiceBus.MSDependencyInjection) they really need? – the_inquisitor Feb 18 '20 at 17:04