{"record":{"id":"ec311e682e6d5b01","repo":"elsa-workflows/elsa-core","slug":"can-t-find-method-name-methodname-on-type-activitytype-or","errorCode":null,"errorMessage":"Can't find method name {methodName} on type {activityType} or its base type {activityType.BaseType}","messagePattern":"Can't find method name (.+?) on type (.+?) or its base type (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Workflows.Core/Extensions/ActivityExtensions.cs","lineNumber":254,"sourceCode":"\n        /// <summary>\n        /// Gets the method for the specified method name on the specified activity.\n        /// </summary>\n        public TDelegate GetDelegate<TDelegate>(string methodName) where TDelegate : Delegate\n        {\n            var activityType = activity.GetType();\n            const BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;\n            var resumeMethodInfo = default(MethodInfo?);\n            var currentType = activityType;\n\n            while (currentType != null && resumeMethodInfo == null)\n            {\n                resumeMethodInfo = currentType.GetMethod(methodName, bindingFlags);\n                currentType = currentType.BaseType;\n            }\n\n            if (resumeMethodInfo == null)\n                throw new Exception($\"Can't find method name {methodName} on type {activityType} or its base type {activityType.BaseType}\");\n\n            return resumeMethodInfo.IsStatic ? (TDelegate)Delegate.CreateDelegate(typeof(TDelegate), resumeMethodInfo) : (TDelegate)Delegate.CreateDelegate(typeof(TDelegate), activity, resumeMethodInfo);\n        }\n\n        /// <summary>\n        /// Gets the Resume method for the specified activity.\n        /// </summary>\n        public ExecuteActivityDelegate GetResumeActivityDelegate(string resumeMethodName) => activity.GetDelegate<ExecuteActivityDelegate>(resumeMethodName);\n\n        /// <summary>\n        /// Gets the Child Activity Completed method for the specified activity.\n        /// </summary>\n        public ActivityCompletionCallback GetActivityCompletionCallback(string completionMethodName) => activity.GetDelegate<ActivityCompletionCallback>(completionMethodName);\n    }\n}","sourceCodeStart":236,"sourceCodeEnd":269,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Core/Extensions/ActivityExtensions.cs#L236-L269","documentation":"Thrown by the delegate-resolution helper in ActivityExtensions when reflection cannot find a method with the given methodName on the activity type or any of its base types. Elsa uses this to bind resume/execute-style callbacks to activity methods.","triggerScenarios":"Calling GetDelegate/GetMethod-style helpers (e.g., via a derived activity) with a method name that does not exist as a public instance method on the activity type or any ancestor - typically a misspelled \"ExecuteAsync\"/\"ResumeAsync\" override or a method with the wrong accessibility/signature.","commonSituations":"Renaming ExecuteAsync/ResumeAsync in a custom activity while base class or scheduling code references the old name; making the method static or private so reflection binding flags miss it; generic or overloaded signatures not matched by GetMethod.","solutions":["Verify the method name string exactly matches a public instance method on the activity (or add the missing override).","Ensure the method is not static and matches the expected delegate signature (ValueTask ExecuteAsync(ActivityExecutionContext)).","Declare the method on the activity type itself (overriding the base) instead of relying on a differently-named helper.","Use nameof to derive the method name at compile time."],"exampleFix":"// before\nprotected override ValueTask RunAsync(ActivityExecutionContext context) { ... } // wrong name for resume lookup\n\n// after\nprotected override async ValueTask ExecuteAsync(ActivityExecutionContext context) { ... }\n// or reference via nameof(ExecuteAsync) when configuring delegates","handlingStrategy":"validation","validationCode":"var method = typeof(MyActivity).GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance);\nif (method is null) throw new InvalidOperationException($\"{methodName} missing on {typeof(MyActivity)}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use nameof(ExecuteAsync) instead of string literals for method names.","Keep activity entry methods public instance methods with the expected signature.","Avoid renaming ExecuteAsync/ResumeAsync overrides without checking delegate bindings."],"tags":["reflection","activity","csharp"],"backgroundTag":"method-not-implemented","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}