Unity-Technologies/UnityCsReference · error · ArgumentException
Method {0}.{1}({2}) not found in assembly {3}!
Error message
Method {0}.{1}({2}) not found in assembly {3}! What it means
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.
Source
Thrown at Editor/Mono/Macros/MethodEvaluator.cs:121
}
}
public static object Eval(string assemblyFile, string typeName,
string methodName, Type[] paramTypes, object[] args)
{
if (!File.Exists(assemblyFile))
{
throw new FileNotFoundException("The specified assembly file could not be found.", assemblyFile);
}
var assemblyDirectory = Path.GetDirectoryName(assemblyFile);
// AssemblyResolve may be called from the context of Default AssemblyLoadContext
// That breaks Code Reload on CoreCLR
var assembly = CurrentAssemblies.LoadFromPath(assemblyFile);
var method = assembly.GetType(typeName, true).GetMethod(methodName,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static,
null, paramTypes, null);
if (method == null)
throw new ArgumentException(string.Format(
"Method {0}.{1}({2}) not found in assembly {3}!", typeName,
methodName, ToCommaSeparatedString(paramTypes),
assembly.FullName));
return method.Invoke(null, args);
}
private static Type TypeOrTypeName(object o)
{
switch (o)
{
case Type t:
return t;
case string s:
return Type.GetType(s);
default:
throw new FormatException($"Expected {o} to be a string or a Type. It is a {o.GetType()}");
}
}View on GitHub (pinned to 225b0fbdb5)
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.
Example fix
// before
MethodEvaluator.Eval(asm, typeName, methodName, paramTypes, args);
// after
var method = Assembly.LoadFrom(asm).GetType(typeName)
?.GetMethod(methodName, BindingFlags.Static|BindingFlags.NonPublic|BindingFlags.Public,
null, paramTypes, null);
if (method == null) throw new InvalidOperationException("Method signature mismatch; refresh eval payload.");
MethodEvaluator.Eval(asm, typeName, methodName, paramTypes, args); Defensive patterns
Strategy: validation
Validate before calling
var t = Assembly.LoadFrom(assemblyFile).GetType(typeName);
if (t?.GetMethod(methodName, BindingFlags.Static|BindingFlags.Public|BindingFlags.NonPublic, null, paramTypes, null) == null) throw new InvalidOperationException("Signature mismatch; refresh payload."); Try / catch
try { MethodEvaluator.Eval(...); }
catch (ArgumentException ex) when (ex.Message.Contains("not found in assembly")) { Debug.LogError($"Refresh eval payload: {ex.Message}"); } Prevention
- Re-derive method metadata from current source
- Match paramTypes exactly including ref/out
- Recompile after renames
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- The specified assembly file could not be found.
- Expected {o} to be a string or a Type. It is a {o.GetType()}
- Expected {o} to be a string[] or a Type[]. It is a {o.GetTyp
- Invalid EvalDataParcel. Could not find type {evalDataParcel.
- Invalid EvalDataParcel data for external code execution.
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/64fed4365042f039.
Report an issue: GitHub.