{"record":{"id":"64fed4365042f039","repo":"Unity-Technologies/UnityCsReference","slug":"method-0-1-2-not-found-in-assembly-3","errorCode":null,"errorMessage":"Method {0}.{1}({2}) not found in assembly {3}!","messagePattern":"Method (.+?)\\.(.+?)\\((.+?)\\) not found in assembly (.+?)!","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Macros/MethodEvaluator.cs","lineNumber":121,"sourceCode":"            }\n        }\n\n        public static object Eval(string assemblyFile, string typeName,\n            string methodName, Type[] paramTypes, object[] args)\n        {\n            if (!File.Exists(assemblyFile))\n            {\n                throw new FileNotFoundException(\"The specified assembly file could not be found.\", assemblyFile);\n            }\n            var assemblyDirectory = Path.GetDirectoryName(assemblyFile);\n            // AssemblyResolve may be called from the context of Default AssemblyLoadContext\n            // That breaks Code Reload on CoreCLR\n            var assembly = CurrentAssemblies.LoadFromPath(assemblyFile);\n            var method = assembly.GetType(typeName, true).GetMethod(methodName,\n                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static,\n                null, paramTypes, null);\n            if (method == null)\n                throw new ArgumentException(string.Format(\n                    \"Method {0}.{1}({2}) not found in assembly {3}!\", typeName,\n                    methodName, ToCommaSeparatedString(paramTypes),\n                    assembly.FullName));\n            return method.Invoke(null, args);\n        }\n\n        private static Type TypeOrTypeName(object o)\n        {\n            switch (o)\n            {\n                case Type t:\n                    return t;\n                case string s:\n                    return Type.GetType(s);\n                default:\n                    throw new FormatException($\"Expected {o} to be a string or a Type. It is a {o.GetType()}\");\n            }\n        }","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Macros/MethodEvaluator.cs#L103-L139","documentation":"Thrown by MethodEvaluator.Eval after the assembly loads successfully but the requested static method cannot be located by name and parameter types via reflection. The exception reports the type name, method name, parameter signature, and assembly to aid debugging.","triggerScenarios":"Passing a typeName/methodName/paramTypes combination that does not exist in the loaded assembly — renamed or removed method, wrong type, or a parameter-type array that does not match the overload.","commonSituations":"Macro/eval payloads cached from a previous code version where the method signature changed after a refactor. Mismatch between the runtime types in paramTypes and the method's actual parameter types (e.g. ref/out modifiers, enum vs int).","solutions":["Re-derive typeName, methodName, and paramTypes from the current source via reflection rather than a cached payload.","Confirm the method is public or non-public static and that paramTypes exactly match including element/ref kinds.","Recompile the target assembly and re-resolve the method metadata."],"exampleFix":"// before\nMethodEvaluator.Eval(asm, typeName, methodName, paramTypes, args);\n\n// after\nvar method = Assembly.LoadFrom(asm).GetType(typeName)\n    ?.GetMethod(methodName, BindingFlags.Static|BindingFlags.NonPublic|BindingFlags.Public,\n                null, paramTypes, null);\nif (method == null) throw new InvalidOperationException(\"Method signature mismatch; refresh eval payload.\");\nMethodEvaluator.Eval(asm, typeName, methodName, paramTypes, args);","handlingStrategy":"validation","validationCode":"var t = Assembly.LoadFrom(assemblyFile).GetType(typeName);\nif (t?.GetMethod(methodName, BindingFlags.Static|BindingFlags.Public|BindingFlags.NonPublic, null, paramTypes, null) == null) throw new InvalidOperationException(\"Signature mismatch; refresh payload.\");","typeGuard":null,"tryCatchPattern":"try { MethodEvaluator.Eval(...); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"not found in assembly\")) { Debug.LogError($\"Refresh eval payload: {ex.Message}\"); }","preventionTips":["Re-derive method metadata from current source","Match paramTypes exactly including ref/out","Recompile after renames"],"tags":["unity","editor","macros","reflection","method-resolution"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}