elsa-workflows/elsa-core · error · InvalidOperationException
Method ' ' not found on type ' '.
Error message
Method '{methodName}' not found on type '{HostType.Name}'. What it means
Thrown by HostMethodActivity.ResolveMethod when the configured method name cannot be found on the HostType using reflection (instance or static, public or non-public). The HostMethod activity executes a named method on a host type, so a missing method name makes execution impossible.
Solutions
- Correct the MethodName value on the activity to exactly match a method on HostType (name is case-sensitive).
- Verify HostType is the intended type; fix the activity's Type/HostType configuration if it points at the wrong class.
- Restore or keep a compatibility method on the host type if existing workflow definitions reference the old name.
- Consider changing the method from private in a base type to be discoverable, or move lookup to the declaring type.
Example fix
// before activity.HostType = typeof(OrderService); activity.MethodName = "ProcessOrder"; // renamed to ProcessAsync // after activity.HostType = typeof(OrderService); activity.MethodName = nameof(OrderService.ProcessAsync);
Defensive patterns
Strategy: validation
Validate before calling
var flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
if (string.IsNullOrWhiteSpace(methodName) || hostType.GetMethod(methodName, flags) is null)
throw new InvalidOperationException($"Method '{methodName}' does not exist on {hostType.FullName}."); Type guard
bool HostHasMethod(Type hostType, string name) => !string.IsNullOrWhiteSpace(name) && hostType.GetMethod(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) is not null;
Try / catch
try
{
await hostMethodActivity.ExecuteAsync(context);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("not found on type"))
{
logger.LogError(ex, "HostMethod '{Method}' missing on {Type}; check workflow definition against current host assembly", methodName, hostType.Name);
} Prevention
- Set MethodName via nameof(...) so refactors update it at compile time.
- Treat host-type method renames as breaking changes for deployed workflows; keep compatibility shims.
- Integration-test workflows that invoke host methods in CI against the current assemblies.
When it happens
Trigger: Setting the MethodName (workflow property or designer field) to a name that does not exist on HostType, typos or case mismatches, the method being renamed or removed in a newer host assembly, or the overload lookup failing because GetMethod(name) cannot disambiguate multiple overloads (AmbiguousMatchException aside) or the method exists on a base type with different accessibility.
Common situations: Workflows persisted against an older version of the host class that has since been refactored, moving a method to a different class, and renaming methods without updating workflow definitions.
Related errors
- Can't find method name
- Multiple Invoke methods were found. Use either Invoke or…
- Multiple Invoke methods were found. Use either Invoke or…
- No Invoke methods were found. Use either Invoke or…
- No Invoke methods were found. Use either Invoke or…
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/331b2a5ee24fd087.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Workflows.Management/Activities/HostMethod/HostMethodActivity.cs:82
{
var callbackMethodName = bookmark.CallbackMethodName;
if (string.IsNullOrWhiteSpace(callbackMethodName))
continue;
bookmark.CallbackMethodName = nameof(ResumeAsync);
var metadata = bookmark.Metadata ?? new Dictionary<string, string>();
metadata["HostMethodActivityResumeCallback"] = callbackMethodName;
bookmark.Metadata = metadata;
}
}
private MethodInfo ResolveMethod(string methodName)
{
var method = HostType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (method == null)
throw new InvalidOperationException($"Method '{methodName}' not found on type '{HostType.Name}'.");
return method;
}
private async ValueTask<object?[]> BuildArgumentsAsync(MethodInfo method, IReadOnlyCollection<InputDescriptor> inputDescriptors, ActivityExecutionContext context, IServiceProvider serviceProvider, CancellationToken cancellationToken)
{
var parameters = method.GetParameters();
var args = new object?[parameters.Length];
// Allow multiple providers; call in order.
var providers = serviceProvider.GetServices<IHostMethodParameterValueProvider>().ToList();
if (providers.Count == 0)
providers.Add(new DefaultHostMethodParameterValueProvider());
for (var i = 0; i < parameters.Length; i++)
{
var parameter = parameters[i];
View on GitHub (pinned to fe9217bdfa)