{"record":{"id":"f1355aa30debe8a7","repo":"pardeike/Harmony","slug":"no-method-found-for-typecolonmethodname-parameters","errorCode":null,"errorMessage":"No method found for {typeColonMethodname}, parameters={parameters.Description()}, generics={generics.Description()}","messagePattern":"No method found for (.+?), parameters=(.+?), generics=(.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Harmony/Public/CodeInstruction.cs","lineNumber":128,"sourceCode":"\t\t/// <returns>A code instruction that calls the method matching the arguments</returns>\r\n\t\t///\r\n\t\tpublic static CodeInstruction Call(Type type, string name, Type[] parameters = null, Type[] generics = null)\r\n\t\t{\r\n\t\t\tvar method = AccessTools.Method(type, name, parameters, generics);\r\n\t\t\tif (method is null) throw new ArgumentException($\"No method found for type={type}, name={name}, parameters={parameters.Description()}, generics={generics.Description()}\");\r\n\t\t\treturn new CodeInstruction(OpCodes.Call, method);\r\n\t\t}\r\n\r\n\t\t/// <summary>Creates a CodeInstruction calling a method (CALL)</summary>\r\n\t\t/// <param name=\"typeColonMethodname\">The target method in the form <c>TypeFullName:MethodName</c>, where the type name matches a form recognized by <a href=\"https://docs.microsoft.com/en-us/dotnet/api/system.type.gettype\">Type.GetType</a> like <c>Some.Namespace.Type</c>.</param>\r\n\t\t/// <param name=\"parameters\">Optional parameters to target a specific overload of the method</param>\r\n\t\t/// <param name=\"generics\">Optional list of types that define the generic version of the method</param>\r\n\t\t/// <returns>A code instruction that calls the method matching the arguments</returns>\r\n\t\t///\r\n\t\tpublic static CodeInstruction Call(string typeColonMethodname, Type[] parameters = null, Type[] generics = null)\r\n\t\t{\r\n\t\t\tvar method = AccessTools.Method(typeColonMethodname, parameters, generics);\r\n\t\t\tif (method is null) throw new ArgumentException($\"No method found for {typeColonMethodname}, parameters={parameters.Description()}, generics={generics.Description()}\");\r\n\t\t\treturn new CodeInstruction(OpCodes.Call, method);\r\n\t\t}\r\n\r\n\t\t/// <summary>Creates a CodeInstruction calling a method (CALL)</summary>\r\n\t\t/// <param name=\"expression\">The lambda expression using the method</param>\r\n\t\t/// <returns>A new Codeinstruction</returns>\r\n\t\t///\r\n\t\tpublic static CodeInstruction Call(Expression<Action> expression) => new(OpCodes.Call, SymbolExtensions.GetMethodInfo(expression));\r\n\r\n\t\t/// <summary>Creates a CodeInstruction calling a method (CALL)</summary>\r\n\t\t/// <param name=\"expression\">The lambda expression using the method</param>\r\n\t\t/// <returns>A new Codeinstruction</returns>\r\n\t\t///\r\n\t\tpublic static CodeInstruction Call<T>(Expression<Action<T>> expression) => new(OpCodes.Call, SymbolExtensions.GetMethodInfo(expression));\r\n\r\n\t\t/// <summary>Creates a CodeInstruction calling a method (CALL)</summary>\r\n\t\t/// <param name=\"expression\">The lambda expression using the method</param>\r\n\t\t/// <returns>A new Codeinstruction</returns>\r","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/pardeike/Harmony/blob/e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c/Harmony/Public/CodeInstruction.cs#L110-L146","documentation":"Like the Type-based overload, this CodeInstruction.Call overload parses a 'TypeFullName:MethodName' string, resolves it with AccessTools.Method, and throws ArgumentException if the resolution yields null after applying the parameters/generics filters.","triggerScenarios":"Passing a malformed or wrong typeColonMethodname (bad namespace, renamed type, missing ':Method' part), or a correctly formed string whose method does not exist or does not match the given parameters/generics.","commonSituations":"Hard-coded 'Namespace.Type:Method' strings that break when the target assembly is refactored; assembly-qualified names failing because Type.GetType cannot resolve the type in the current context; overload ambiguity resolved incorrectly by parameters.","solutions":["Fix the typeColonMethodname string to the exact type full name and method name","Prefer the typeof(T)-based Call overload to get compile-time safety","Supply parameters/generics arrays that match an actual overload","Null-check AccessTools.Method(typeColonMethodname, parameters, generics) at patch init and fail with a clear log"],"exampleFix":"// before\nCodeInstruction.Call(\"My.App.Logger:WriteMsg\")\n// after\nCodeInstruction.Call(\"My.App.Logger:WriteMessage\", new[] { typeof(string) })","handlingStrategy":"validation","validationCode":"var mi = AccessTools.Method(typeColonMethodname, parameters, generics);\nif (mi is null) throw new InvalidOperationException($\"Cannot resolve {typeColonMethodname}\");","typeGuard":null,"tryCatchPattern":"try { il.Append(CodeInstruction.Call(typeColonMethodname, parameters)); } catch (ArgumentException ex) { log.Error($\"Cannot resolve {typeColonMethodname}: {ex.Message}\"); throw; }","preventionTips":["Prefer typeof(T)-based Call over Type:Method strings","Validate the string with AccessTools.Method before emitting","Track target-assembly refactors that rename types or methods"],"tags":["transpiler","reflection","method-resolution","csharp"],"backgroundTag":"resource-not-found","analyzedSha":"e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c","analyzedAt":"2026-09-15T22:47:11.550Z","contentChangedAt":"2026-09-15T22:47:11.550Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}