Closed CommitedSajmon closed 6 months ago
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stalled for 14 days with no activity.
Registering services using
AddMediatRClasses(IServiceCollection services, MediatRServiceConfiguration configuration)
throwsSystem.Reflection.AmbiguousMatchException
athandlerType.GetInterface(handlerInterface.Name)
https://github.com/jbogard/MediatR/blob/6baaeef7a16ca75cb905829f870f79c6334ef40e/src/MediatR/Registration/ServiceRegistrar.cs#L132C56-L132C68
The exception is thrown when certain conditions are met:
Below call
typeof(Handler3).GetInterface(typeof(IRequestHandler<SampleRequest>).Name)
throws the beforementionedSystem.Reflection.AmbiguousMatchException
asHandler3
is a type that implements the same generic interface"IRequestHandler`1"
with different type argumentsI am aware that
IRequest
is being sent to exactly oneIRequestHandler
, but the real use case is deprecating Handler1 and Handler2 in favor of the newHandler3
. AddingHandler3
to assembly shouldn't break the wholeMediatR
registration