{"record":{"id":"68b67e3e7182d14d","repo":"LuckyPennySoftware/AutoMapper","slug":"cannot-find-suitable-method-type-methodname-p","errorCode":null,"errorMessage":"Cannot find suitable method {type}.{methodName}({parametersCount} parameters).","messagePattern":"Cannot find suitable method (.+?)\\.(.+?)\\((.+?) parameters\\)\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/AutoMapper/Internal/TypeExtensions.cs","lineNumber":19,"sourceCode":"using System.Collections;\nusing System.Dynamic;\nnamespace AutoMapper.Internal;\n\npublic static class TypeExtensions\n{\n    public const BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;\n    public const BindingFlags StaticFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;\n\n    public static MethodInfo StaticGenericMethod(this Type type, string methodName, int parametersCount)\n    {\n        foreach (MethodInfo foundMethod in type.GetMember(methodName, MemberTypes.Method, StaticFlags & ~BindingFlags.NonPublic))\n        {\n            if (foundMethod.IsGenericMethodDefinition && foundMethod.GetParameters().Length == parametersCount)\n            {\n                return foundMethod;\n            }\n        }\n        throw new ArgumentOutOfRangeException(nameof(methodName), $\"Cannot find suitable method {type}.{methodName}({parametersCount} parameters).\");\n    }\n\n    public static void CheckIsDerivedFrom(this Type derivedType, Type baseType)\n    {\n        if (!baseType.IsAssignableFrom(derivedType) && !derivedType.IsGenericTypeDefinition && !baseType.IsGenericTypeDefinition)\n        {\n            throw new ArgumentOutOfRangeException(nameof(derivedType), $\"{derivedType} is not derived from {baseType}.\");\n        }\n    }\n\n    public static bool IsDynamic(this Type type) => typeof(IDynamicMetaObjectProvider).IsAssignableFrom(type);\n\n    public static IEnumerable<Type> BaseClassesAndInterfaces(this Type type)\n    {\n        var currentType = type;\n        while ((currentType = currentType.BaseType) != null)\n        {\n            yield return currentType;","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/LuckyPennySoftware/AutoMapper/blob/dfa6dd587c5854b4beee5934beb39ba6e9569b84/src/AutoMapper/Internal/TypeExtensions.cs#L1-L37","documentation":"Internal error thrown by TypeExtensions.StaticGenericMethod when no public static generic method (IsGenericMethodDefinition) with the specified name and parameter count exists on the type. The method searches via GetMember with StaticFlags minus NonPublic. This is an internal reflection helper used by AutoMapper's own code paths, not typically called by end users directly.","triggerScenarios":"AutoMapper's internal code calls StaticGenericMethod for an expected method name on a type, but that method does not exist — typically due to a version mismatch, a missing extension method, or a type that does not have the expected static generic method.","commonSituations":"Referenced AutoMapper version is inconsistent across assemblies; a custom IObjectMapper or extension returns a type missing an expected method; extremely rare for standard usage.","solutions":["Check the call stack to identify which type and method name AutoMapper was searching for.","Ensure all referenced AutoMapper packages are the same version across the solution.","If using custom mappers or extensions, verify the types they return have the expected static generic methods.","File a bug report with the full stack trace if using standard AutoMapper APIs."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    var config = new MapperConfiguration(cfg => { /* ... */ });\n    config.CompileMaps();\n}\ncatch (ArgumentOutOfRangeException ex) when (ex.Message.Contains(\"Cannot find suitable method\"))\n{\n    // Inspect the stack trace to find which type/method AutoMapper was searching for\n    logger.LogError(ex, \"Internal reflection lookup failed. Check AutoMapper version consistency.\");\n}","preventionTips":["Ensure all AutoMapper NuGet packages across the solution reference the same version.","Keep custom IObjectMapper implementations in sync with the AutoMapper API surface.","Report internal reflection errors with a full reproduction if using standard APIs."],"tags":["internal","reflection","method-lookup","version-mismatch"],"backgroundTag":null,"analyzedSha":"dfa6dd587c5854b4beee5934beb39ba6e9569b84","analyzedAt":"2026-08-13T19:56:33.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}