elsa-workflows/elsa-core · error · Exception

Can't find method name

Error message

Can't find method name {methodName} on type {activityType} or its base type {activityType.BaseType}

What it means

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.

Solutions

  1. Verify the method name string exactly matches a public instance method on the activity (or add the missing override).
  2. Ensure the method is not static and matches the expected delegate signature (ValueTask ExecuteAsync(ActivityExecutionContext)).
  3. Declare the method on the activity type itself (overriding the base) instead of relying on a differently-named helper.
  4. Use nameof to derive the method name at compile time.

Example fix

// before
protected override ValueTask RunAsync(ActivityExecutionContext context) { ... } // wrong name for resume lookup

// after
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) { ... }
// or reference via nameof(ExecuteAsync) when configuring delegates
Defensive patterns

Strategy: validation

Validate before calling

var method = typeof(MyActivity).GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance);
if (method is null) throw new InvalidOperationException($"{methodName} missing on {typeof(MyActivity)}");

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13). Data as JSON: /api/errors/ec311e682e6d5b01. Report an issue: GitHub.

Appendix: source

Thrown at src/modules/Elsa.Workflows.Core/Extensions/ActivityExtensions.cs:254

        /// <summary>
        /// Gets the method for the specified method name on the specified activity.
        /// </summary>
        public TDelegate GetDelegate<TDelegate>(string methodName) where TDelegate : Delegate
        {
            var activityType = activity.GetType();
            const BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
            var resumeMethodInfo = default(MethodInfo?);
            var currentType = activityType;

            while (currentType != null && resumeMethodInfo == null)
            {
                resumeMethodInfo = currentType.GetMethod(methodName, bindingFlags);
                currentType = currentType.BaseType;
            }

            if (resumeMethodInfo == null)
                throw new Exception($"Can't find method name {methodName} on type {activityType} or its base type {activityType.BaseType}");

            return resumeMethodInfo.IsStatic ? (TDelegate)Delegate.CreateDelegate(typeof(TDelegate), resumeMethodInfo) : (TDelegate)Delegate.CreateDelegate(typeof(TDelegate), activity, resumeMethodInfo);
        }

        /// <summary>
        /// Gets the Resume method for the specified activity.
        /// </summary>
        public ExecuteActivityDelegate GetResumeActivityDelegate(string resumeMethodName) => activity.GetDelegate<ExecuteActivityDelegate>(resumeMethodName);

        /// <summary>
        /// Gets the Child Activity Completed method for the specified activity.
        /// </summary>
        public ActivityCompletionCallback GetActivityCompletionCallback(string completionMethodName) => activity.GetDelegate<ActivityCompletionCallback>(completionMethodName);
    }
}

View on GitHub (pinned to fe9217bdfa)