rebus-org / Rebus.ServiceProvider

:bus: Microsoft Extensions Dependency Injection container adapter for Rebus
https://mookid.dk/category/rebus
Other
65 stars 32 forks source link

Rebus.ServiceProvider + Rebus.Autofac last versions don't work. #30

Closed VladislavMorozov closed 4 years ago

VladislavMorozov commented 4 years ago

I have asp.net core 3.1 application, "Rebus.ServiceProvider" Version="5.0.2", "Rebus.ServiceProvider" Version="5.0.2", "Rebus.RabbitMq" Version="6.0.0", "Rebus.Autofac" Version="7.0.0". I registered rebus from Rebus.Autofac builder.RegisterRebus(configure => ...); in Startup.cs public IServiceProvider ConfigureServices(IServiceCollection services) and use app.ApplicationServices.UseRebus(bus => ...); from Rebus.ServiceProvider in public void Configure(IApplicationBuilder app). I caught this exception.

https://user-images.githubusercontent.com/31768904/75884503-ff6f8e00-5e35-11ea-8281-70e006657f07.png

mookid8000 commented 4 years ago

Ok, so now I read this page about how Autofac integrates with ASP.NET Core – I did not know that that was how you were supposed to integrate Autofac these days.

Since calling .UseRebus() on the IServiceProvider seems to work, I suggest you don't 🙂

Also, Rebus' Autofac integration works by starting the bus when you call builder.Build(); (where builder is the Autofac ContainerBuilder, so there's no need to do additional things to get the bus started.

This also means that you can ditch the dependency on Rebus.ServiceProvider.