Closed fh-andri closed 11 months ago
You miss something in your registration code (which you didn't post here).
https://github.com/jbogard/MediatR/wiki first Paragraph: Setup
make sure to register the assemblies of your other projects too.
@remcoros I have added the setup on both projects to DI. Both project are having MediatR installed as well. Here is the code
services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
cfg.AddRequestPreProcessor(typeof(IRequestPreProcessor<>), typeof(PipelinePreProcessor<>));
cfg.AddRequestPostProcessor(typeof(IRequestPostProcessor<,>), typeof(PipelinePostProcessor<,>));
});
You are using Assembly.GetExecutingAssembly(). That only scans the current assembly, not the assemblies of other projects. That should be fixed to pick up types from your other projects as well
@remcoros Thank you! I was not realize it and thinking all registered correctly because of the pipeline is working. Have a good day!
Hi,
I have an API solution with 2 projects and using MediatR 12.1.1. First project has MediatR preprocessor and the exception handler and the other one has the request handler. The preprocessor is working fine even it's on separate project with the request handler but not with the exception handler. The exception does not trigger the handler if I put the exception handler class separately with the request handler. But if I put the exception handler class in same project with the request handler, it works. What would be the issue I have here?
Thank you!