Hello Jimmy,
I am getting an unhandled exception occurred while processing the request "InvalidOperationException: Unable to resolve service for type 'MediatR.Mediator' while attempting to activate 'NaijaEvent.Service.Controllers.EventController'"
See my startup class
```c#
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NaijaEvent.Application.NEvents.Command.CreateEvent;
using NaijaEvent.Application.NEvents.Query;
using NaijaEvent.Persistance;
using MediatR;
using System.Reflection;
using Swashbuckle.AspNetCore.Swagger;
using AutoMapper;
using NaijaEvent.Application.NEvents;
namespace NaijaEvent.Service
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// services.AddMediatR(typeof(GetNEventDetailsHandler).GetTypeInfo().Assembly);
services.AddAutoMapper(typeof(NEventProfile).Assembly);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2).AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<CreateEventCommandValidator>());
services.AddDbContext<NaijaEventContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("NaijaEventDatabase")));
services.AddMediatR(typeof(CreateEventCommand).Assembly);
```
I'm not seeing anything wrong - do you have a link to a more complete example?
Hello Jimmy
see link to the repository
https://github.com/etechnologiesng/NaijaEventAPICleanArchitecture
Please help
Please replace Mediator with IMediator
private readonly IMediator _mediator;
public EventController(IMediator mediator)
{
_mediator = mediator;
}
Most helpful comment
Please replace Mediator with IMediator