jbogard / MediatR.Extensions.Microsoft.DependencyInjection

MediatR extensions for Microsoft.Extensions.DependencyInjection
MIT License
326 stars 90 forks source link

Getting registration error using dependency injection. #85

Closed marbletravis closed 4 years ago

marbletravis commented 4 years ago

I have been using MediatR in dotnet core 2.x for a couple of years now without any issues.

Today I decided to upgrade to dotnet core 3.1 and with it upgrade to the latest version of MediatR 8.0.x

The signature for AddMediatR changed, upon consulting the documentation, I tried: services.AddMediatR(typeof(Startup).GetTypeInfo().Assembly);

which did not work, I get an error saying

Register your handlers with the container. See the samples in GitHub for examples.

I have tried to find answers on the internet to no avail.

What I am doing wrong? Is there an upgrade guide for MediatR?

Thanks

marbletravis commented 4 years ago

I figured it out, I was thrown off by the readme, this is what I wanted:

services.AddMediatR(typeof(MyHandler));

with MyHandler being replaced by something from the assembly that had my handlers.