{"record":{"id":"7752dbf449c3ff49","repo":"LuckyPennySoftware/MediatR","slug":"could-not-find-method-nameof-irequestexceptionact","errorCode":null,"errorMessage":"Could not find method {nameof(IRequestExceptionAction<TRequest, Exception>.Execute)} on type {exceptionActionInterfaceType}","messagePattern":"Could not find method (.+?) on type (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/MediatR/Pipeline/RequestExceptionActionProcessorBehavior.cs","lineNumber":87,"sourceCode":"\n    private IEnumerable<(Type ExceptionType, object Action)> GetActionsForException(Type exceptionType, TRequest request)\n    {\n        var exceptionActionInterfaceType = typeof(IRequestExceptionAction<,>).MakeGenericType(typeof(TRequest), exceptionType);\n        var enumerableExceptionActionInterfaceType = typeof(IEnumerable<>).MakeGenericType(exceptionActionInterfaceType);\n\n        var actionsForException = (IEnumerable<object>)_serviceProvider.GetRequiredService(enumerableExceptionActionInterfaceType);\n\n        return HandlersOrderer.Prioritize(actionsForException.ToList(), request)\n            .Select(action => (exceptionType, action));\n    }\n\n    private static MethodInfo GetMethodInfoForAction(Type exceptionType)\n    {\n        var exceptionActionInterfaceType = typeof(IRequestExceptionAction<,>).MakeGenericType(typeof(TRequest), exceptionType);\n\n        var actionMethodInfo =\n            exceptionActionInterfaceType.GetMethod(nameof(IRequestExceptionAction<TRequest, Exception>.Execute))\n            ?? throw new InvalidOperationException(\n                $\"Could not find method {nameof(IRequestExceptionAction<TRequest, Exception>.Execute)} on type {exceptionActionInterfaceType}\");\n\n        return actionMethodInfo;\n    }\n}\n","sourceCodeStart":69,"sourceCodeEnd":93,"githubUrl":"https://github.com/LuckyPennySoftware/MediatR/blob/916ef1b3d68ccdc96db8f914eaf1b32fc7db52c5/src/MediatR/Pipeline/RequestExceptionActionProcessorBehavior.cs#L69-L93","documentation":"Thrown by GetMethodInfoForAction if reflection cannot find the Execute method on the synthesized IRequestExceptionAction<TRequest, TException> interface built via MakeGenericType. This is a defensive guard: under normal .NET behavior Execute always exists on that interface, so this firing indicates a corrupted build, a non-conforming runtime, or an exotic reflection/proxying environment.","triggerScenarios":"Effectively never under standard .NET: the interface is constructed from IRequestExceptionAction<,> which declares Execute. Could surface with dynamic proxies / IL weaving that strip interface methods, partial-trust reflection limits, or a hand-edited/incompatible MediatR binary.","commonSituations":"Dynamic proxy frameworks (Castle DynamicProxy, Moq) generating type mocks without the method; AOP weavers altering the interface; mismatched MediatR assembly versions where the interface shape changed.","solutions":["Verify the MediatR package version matches across all referenced assemblies (no version mismatch).","If proxying/weaving exception actions, ensure the proxy retains the Execute method on the IRequestExceptionAction<,> interface.","Run a clean rebuild to rule out stale/compiled artifacts.","As a last resort, isolate the exception action in a minimal project to confirm the runtime can resolve the method."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Sanity check the interface shape before relying on it\nvar method = typeof(IRequestExceptionAction<MyRequest, MyException>).GetMethod(\"Execute\");\nDebug.Assert(method is not null, \"Execute must exist on IRequestExceptionAction<,>\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin MediatR to a single version across the solution to avoid interface-shape drift.","Avoid proxying/weaving IRequestExceptionAction types unless you preserve Execute."],"tags":["pipeline","exception-action","reflection","defensive"],"backgroundTag":null,"analyzedSha":"916ef1b3d68ccdc96db8f914eaf1b32fc7db52c5","analyzedAt":"2026-08-13T17:57:04.476Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}