I want to add MediatR
to my services.
Here is the code:
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMediatR(Assembly.GetExecutingAssembly());
}
// rest of codes ...
}
Here is the Error:
Error CS1503 Argument 2: cannot convert from 'System.Reflection.Assembly' to 'System.Action<Microsoft.Extensions.DependencyInjection.MediatRServiceConfiguration>'
If you are using [email protected] you can use this:
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
If you still want to use your version of code, then you should install MediatR.Extensions.Microsoft.DependencyInjection package but you might need to downgrade MediatR version to 11
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With