{"record":{"id":"95a586934264c683","repo":"Unity-Technologies/UnityCsReference","slug":"the-specified-assembly-file-could-not-be-found","errorCode":null,"errorMessage":"The specified assembly file could not be found.","messagePattern":"The specified assembly file could not be found\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Macros/MethodEvaluator.cs","lineNumber":111,"sourceCode":"                    {\n                        var assembly = CurrentAssemblies.LoadFromPath(dllPath);\n                        if (assembly != null && Array.Exists(assembly.GetTypes(), t => t.Name == args.Name))\n                            return assembly;\n                    }\n                    catch (Exception)\n                    {\n                    }\n                }\n                return null;\n            }\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        {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Macros/MethodEvaluator.cs#L93-L129","documentation":"Thrown by MethodEvaluator.Eval when the assemblyFile argument does not exist on disk (File.Exists is false). Eval loads the assembly via CurrentAssemblies.LoadFromPath and evaluates a static method in it, so a missing assembly is fatal.","triggerScenarios":"Macro evaluation or external code execution that targets an assembly path which is stale, relative to the wrong directory, or points to an assembly that failed to compile. Also a path with incorrect casing or forward/backslash mismatch.","commonSituations":"Editor macros evaluated after a code reload where the expected assembly path changed (e.g. Player vs Editor assemblies, or ScriptAssemblies output moved). A build pipeline passing a precompiled assembly path that no longer exists.","solutions":["Resolve the assembly path from a known-good location (e.g. the compiled ScriptAssemblies folder) right before evaluation.","Verify File.Exists(assemblyFile) and log the absolute path before calling Eval.","Ensure the target assembly compiled successfully; rebuild if the DLL is absent."],"exampleFix":"// before\nMethodEvaluator.Eval(assemblyFile, typeName, methodName, paramTypes, args);\n\n// after\nif (!File.Exists(assemblyFile))\n    throw new FileNotFoundException($\"Assembly missing: {assemblyFile}\");\nMethodEvaluator.Eval(assemblyFile, typeName, methodName, paramTypes, args);","handlingStrategy":"validation","validationCode":"if (!File.Exists(assemblyFile)) throw new System.IO.FileNotFoundException($\"Assembly missing: {assemblyFile}\");","typeGuard":null,"tryCatchPattern":"try { MethodEvaluator.Eval(assemblyFile, ...); }\ncatch (FileNotFoundException ex) { Debug.LogError($\"Rebuild target assembly: {ex.FileName}\"); }","preventionTips":["Resolve assembly paths from ScriptAssemblies at call time","Verify File.Exists before eval","Rebuild assemblies whose DLLs are absent"],"tags":["unity","editor","macros","reflection","assembly-loading","filesystem"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}