Skip to content

Manual registration of generic handler works, but automatic doesn't. #1087

Open
@matteo-mosca

Description

If I make the following registration:

builder.Services.AddScoped<IRequestHandler<CreateCommand<CreateClientDto, ClientEntity>, Result<ClientEntity>>, CreateHandler<CreateClientDto, ClientEntity>>();

Then at runtime everything is resolved and works. But if I leave it to automatic registration with RegisterGenericHandlers = true I have some weird error (namespaces redacted for brevity, everything is in the same assembly):

System.InvalidOperationException: No service for type 'MediatR.IRequestHandler2[CreateCommand2[CreateClientDto,ClientEntity],Result1[ClientEntity]]' has been registered.`

Which is extremely weird, because manual registration of the very same works.

Am I missing something? I can provide more code if anyone thinks it matters, I honestly think it doesnt, like my classes implementations and such.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions