locked
MediatR Issue RRS feed

  • Question

  • User577498514 posted

    I have used MediatR in previous version of Asp.Net Core and it was working fine but now when i inject services.AddMediatR() it is not working. How can i fix the issue?

    Wednesday, December 25, 2019 6:30 AM

Answers

  • User-1780421697 posted

    Mr Chan Leo, 

    In dot net core 3 MediatR is not integrated directly as it was in previous version so you have to use two packages 

    Packages:

    1: MediatR

    2: MediatR.Extensions.Microsoft.DependencyInjection

    And in Startup file you have to use 

    services.AddMediatR(Assembly.GetExecutingAssembly());

    in startup instead of 

    services.AddMediatR();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 25, 2019 8:21 AM

All replies

  • User303363814 posted

    How can i fix the issue?

    By providing a concise sample of code which reproduces your problem and explaining exactly what the problem is.

    Wednesday, December 25, 2019 6:48 AM
  • User-1780421697 posted

    Mr Chan Leo, 

    In dot net core 3 MediatR is not integrated directly as it was in previous version so you have to use two packages 

    Packages:

    1: MediatR

    2: MediatR.Extensions.Microsoft.DependencyInjection

    And in Startup file you have to use 

    services.AddMediatR(Assembly.GetExecutingAssembly());

    in startup instead of 

    services.AddMediatR();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 25, 2019 8:21 AM
  • User577498514 posted

    What version of MediatR you have used in Dot Net Core 3?

    Wednesday, December 25, 2019 8:40 AM
  • User-1780421697 posted

    Dot Net Core 3.0 and MediatR 7.0.0

    Thursday, December 26, 2019 4:39 AM
  • User-1780421697 posted

    Does that solve your problem, do you need more help like sample code?

    Friday, December 27, 2019 10:09 AM
  • User577498514 posted

    Yeah with some affords at last it works. New version is not working with parameter less constructor.

    Friday, December 27, 2019 10:22 AM