Closed abomadi closed 5 years ago
Most likely you are not scanning project 2 or 3 during start up. Please share the code you are using to register your handlers.
@lilasquared
services.AddMediatR();
services.Scan(scan => scan
.FromAssembliesOf(typeof(IMediator), typeof(TestEvent), typeof(TestCommand)
, typeof(TestEventHandler))
.AddClasses()
.AsImplementedInterfaces());
i call all the required assemblies here FromAssemblies, also all handlers are registered as
services.AddScoped<IRequestHandler<TestCommand>, TestCommandHandler>();
Doesn't the AddMediatR method accept assemblies to scan as parameters? Have you tried that? If you are using the MicrosoftDI MediatR extension it should handle registering the handlers for you.
@lilasquared Yes it does tried both cases actually, as the following:
services.AddMediatR(typeof(IMediator), typeof(TestEvent), typeof(TestCommand), typeof(TestEventHandler));
services.AddScoped<IRequestHandler<TestCommand>, TestCommandHandler>();
all projects are referenced to this one and this is being called on Startup
It's going to be hard to help out with this without more info about the project. Are you able to create a small sample project that replicates the behavior that you can share?
@lilasquared here is a sample project MediatRTest
I think this is in the wrong repository, if you're using the DI extension.
You shouldn't need to register notification handlers, AddMediatR
does that already.
Im trying to use MediatR across multiple class libraries as the following :
if i create handler withing the same class library it works well, however Project 2 and 3 handlers are never triggered, i register all the above using Microsoft DI and Scrutor any help plz ?