Uchenna

InvalidOperationException: No service for type 'MediatR.Mediator' has been registered.

net Icon

System.InvalidOperationException

No service for type 'MediatR.Mediator' has been registered.

An unhandled exception occurred
Exception source not available.

Solution

I changed the mediatR registeration in my startup file to

services.AddMediatR(typeof(Startup).GetTypeInfo().Assembly);

from

services.AddMediatR(typeof(Startup).Assembly);            
Apr 19, 2021 Anyone

1 replies


Uchenna

Alternatively you can also change the dependency injection registeration to services.AddMediatR(AppDomain.CurrentDomain.GetAssemblies()); if you have a multi-project solution


Install the browser extension

Found this solution helpful? Try our extension for quick solutions to your .NET errors.

Chrome logo Add to Chrome - It's free