{"record":{"id":"331b2a5ee24fd087","repo":"elsa-workflows/elsa-core","slug":"method-methodname-not-found-on-type-hosttype-name","errorCode":null,"errorMessage":"Method '{methodName}' not found on type '{HostType.Name}'.","messagePattern":"Method '(.+?)' not found on type '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Workflows.Management/Activities/HostMethod/HostMethodActivity.cs","lineNumber":82,"sourceCode":"        {\n            var callbackMethodName = bookmark.CallbackMethodName;\n            \n            if (string.IsNullOrWhiteSpace(callbackMethodName))\n                continue;\n            \n            bookmark.CallbackMethodName = nameof(ResumeAsync);\n            var metadata = bookmark.Metadata ?? new Dictionary<string, string>();\n            \n            metadata[\"HostMethodActivityResumeCallback\"] = callbackMethodName;\n            bookmark.Metadata = metadata;\n        }\n    }\n\n    private MethodInfo ResolveMethod(string methodName)\n    {\n        var method = HostType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);\n        if (method == null)\n            throw new InvalidOperationException($\"Method '{methodName}' not found on type '{HostType.Name}'.\");\n\n        return method;\n    }\n\n    private async ValueTask<object?[]> BuildArgumentsAsync(MethodInfo method, IReadOnlyCollection<InputDescriptor> inputDescriptors, ActivityExecutionContext context, IServiceProvider serviceProvider, CancellationToken cancellationToken)\n    {\n        var parameters = method.GetParameters();\n        var args = new object?[parameters.Length];\n\n        // Allow multiple providers; call in order.\n        var providers = serviceProvider.GetServices<IHostMethodParameterValueProvider>().ToList();\n        if (providers.Count == 0)\n            providers.Add(new DefaultHostMethodParameterValueProvider());\n\n        for (var i = 0; i < parameters.Length; i++)\n        {\n            var parameter = parameters[i];\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Management/Activities/HostMethod/HostMethodActivity.cs#L64-L100","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nactivity.HostType = typeof(OrderService);\nactivity.MethodName = \"ProcessOrder\"; // renamed to ProcessAsync\n\n// after\nactivity.HostType = typeof(OrderService);\nactivity.MethodName = nameof(OrderService.ProcessAsync);","handlingStrategy":"validation","validationCode":"var flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;\nif (string.IsNullOrWhiteSpace(methodName) || hostType.GetMethod(methodName, flags) is null)\n    throw new InvalidOperationException($\"Method '{methodName}' does not exist on {hostType.FullName}.\");","typeGuard":"bool HostHasMethod(Type hostType, string name) => !string.IsNullOrWhiteSpace(name) && hostType.GetMethod(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) is not null;","tryCatchPattern":"try\n{\n    await hostMethodActivity.ExecuteAsync(context);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not found on type\"))\n{\n    logger.LogError(ex, \"HostMethod '{Method}' missing on {Type}; check workflow definition against current host assembly\", methodName, hostType.Name);\n}","preventionTips":["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."],"tags":["reflection","method-not-found","workflow-activity"],"backgroundTag":"method-not-found","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}