WorkerService configure a RabbitMq with MassTransit

Viewed 621

in a WorkerService .Net I am trying to configure a MassTransit host with RabbitMq but I am getting this Error

Reference to type 'IBusControl' claims it is defined in 'MassTransit', but it could not be found

IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices((context,services) =>
{
    services.AddHostedService<Worker>();

    services.AddAutoMapper(typeof(Program));
    //MassTransit-RabbitMQ Configuration
    services.AddMassTransit(config => {
        config.UsingRabbitMq((ctx, cfg) => {
            cfg.Host(context.Configuration.GetValue<string>("EventBusSettings:HostAddress"));
        });
    });
    services.AddMassTransitHostedService();
})
.Build();

await host.RunAsync();

What am I missing?

1 Answers

You are probably referencing an assembly that is not current. The latest version of MassTransit no longer requires the AddMassTransitHostedService configuration method. More details are available in the documentation.

Related