{"record":{"id":"cd8561d74470a6f5","repo":"LuckyPennySoftware/MediatR","slug":"could-not-find-method-nameof-irequestexceptionhan","errorCode":null,"errorMessage":"Could not find method {nameof(IRequestExceptionHandler<TRequest, TResponse, Exception>.Handle)} on type {exceptionHandlerInterfaceType}","messagePattern":"Could not find method (.+?) on type (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/MediatR/Pipeline/RequestExceptionProcessorBehavior.cs","lineNumber":102,"sourceCode":"    }\n\n    private IEnumerable<(Type ExceptionType, object Handler)> GetHandlersForException(Type exceptionType, TRequest request)\n    {\n        var exceptionHandlerInterfaceType = typeof(IRequestExceptionHandler<,,>).MakeGenericType(typeof(TRequest), typeof(TResponse), exceptionType);\n        var enumerableExceptionHandlerInterfaceType = typeof(IEnumerable<>).MakeGenericType(exceptionHandlerInterfaceType);\n\n        var exceptionHandlers = (IEnumerable<object>) _serviceProvider.GetRequiredService(enumerableExceptionHandlerInterfaceType);\n\n        return HandlersOrderer.Prioritize(exceptionHandlers.ToList(), request)\n            .Select(handler => (exceptionType, action: handler));\n    }\n\n    private static MethodInfo GetMethodInfoForHandler(Type exceptionType)\n    {\n        var exceptionHandlerInterfaceType = typeof(IRequestExceptionHandler<,,>).MakeGenericType(typeof(TRequest), typeof(TResponse), exceptionType);\n        \n        var handleMethodInfo = exceptionHandlerInterfaceType.GetMethod(nameof(IRequestExceptionHandler<TRequest, TResponse, Exception>.Handle))\n                           ?? throw new InvalidOperationException($\"Could not find method {nameof(IRequestExceptionHandler<TRequest, TResponse, Exception>.Handle)} on type {exceptionHandlerInterfaceType}\");\n\n        return handleMethodInfo;\n    }\n}","sourceCodeStart":84,"sourceCodeEnd":106,"githubUrl":"https://github.com/LuckyPennySoftware/MediatR/blob/916ef1b3d68ccdc96db8f914eaf1b32fc7db52c5/src/MediatR/Pipeline/RequestExceptionProcessorBehavior.cs#L84-L106","documentation":"Thrown by GetMethodInfoForHandler if reflection cannot locate the Handle method on the synthesized IRequestExceptionHandler<TRequest,TResponse,TException> interface built via MakeGenericType. This is a defensive invariant: Handle is declared on the interface and should always resolve; firing it points to an abnormal runtime/build/proxying condition, not normal usage.","triggerScenarios":"Should not occur under standard .NET. Possible with dynamic proxies that drop the interface method, IL weavers that alter the interface, partial-trust reflection restrictions, or a corrupt/version-mismatched MediatR assembly.","commonSituations":"Proxy frameworks (Castle, Moq) mocking exception handlers without preserving Handle; AOP weavers; mismatched MediatR versions in the dependency graph.","solutions":["Align MediatR package versions across all projects/assemblies in the solution.","Ensure any proxy/weaver retains the Handle method on the IRequestExceptionHandler<,,> interface.","Clean and rebuild to discard stale compiled artifacts.","Reproduce in a minimal console app to rule out environment-specific reflection limits."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var method = typeof(IRequestExceptionHandler<MyReq, MyResp, MyException>).GetMethod(\"Handle\");\nDebug.Assert(method is not null, \"Handle must exist on IRequestExceptionHandler<,,>\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a single MediatR version in the dependency graph.","Do not strip interface methods when proxying exception handlers."],"tags":["pipeline","exception-handler","reflection","defensive"],"backgroundTag":null,"analyzedSha":"916ef1b3d68ccdc96db8f914eaf1b32fc7db52c5","analyzedAt":"2026-08-13T17:57:04.476Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}