{"record":{"id":"47d05e148c4f4fba","repo":"Unity-Technologies/UnityCsReference","slug":"invalid-evaldataparcel-could-not-find-type-evald","errorCode":null,"errorMessage":"Invalid EvalDataParcel. Could not find type {evalDataParcel.KnownTypeNames[i]} in for external code execution arguments.","messagePattern":"Invalid EvalDataParcel\\. Could not find type (.+?) in for external code execution arguments\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Macros/MethodEvaluator.cs","lineNumber":186,"sourceCode":"                }\n                catch (SerializationException)\n                {\n                    throw new Exception(\"Invalid EvalDataParcel data for external code execution.\");\n                }\n            }\n\n            // Prepare list of known types information. Add EnumSurrogate to support int to enum remapping.\n            var knownTypeNames = new List<Type>() { typeof(MethodEvaluatorSurrogateProvider.EnumSurrogate) };\n            for (var i = 0; i < evalDataParcel.KnownTypeNames.Length; ++i)\n            {\n                // Avoid loading assemblies which are already loaded - empty path means that this type is in system assembly.\n                if (!string.IsNullOrEmpty(evalDataParcel.KnownTypeAssemblyPaths[i]) && File.Exists(evalDataParcel.KnownTypeAssemblyPaths[i]))\n                    CurrentAssemblies.LoadFromPath(evalDataParcel.KnownTypeAssemblyPaths[i]);\n\n                var type = Type.GetType(evalDataParcel.KnownTypeNames[i]);\n                if (type == null)\n                {\n                    throw new Exception($\"Invalid EvalDataParcel. Could not find type {evalDataParcel.KnownTypeNames[i]} in for external code execution arguments.\");\n                }\n                knownTypeNames.Add(type);\n            }\n\n            // Now deserialize the main method call data including arguments\n            EvalRemoteMethodCallParcel evalRemoteMethodCallParcel;\n            using (var methodStream = new MemoryStream(evalDataParcel.RemoteMethodCallParcelData))\n            {\n                // Setting quotas to max to avoid issues with large data.\n                using var reader = XmlDictionaryReader.CreateTextReader(methodStream, XmlDictionaryReaderQuotas.Max);\n                var serializer = new DataContractSerializer(typeof(EvalRemoteMethodCallParcel), knownTypeNames);\n                serializer.SetSerializationSurrogateProvider(new MethodEvaluatorSurrogateProvider());\n                try\n                {\n                    evalRemoteMethodCallParcel = (EvalRemoteMethodCallParcel)serializer.ReadObject(reader, true);\n                }\n                catch (SerializationException)\n                {","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Macros/MethodEvaluator.cs#L168-L204","documentation":"Thrown by ExecuteExternalCode after deserializing EvalDataParcel when a declared known type name cannot be resolved by Type.GetType. The parcel lists known type names (and optional assembly paths) needed to deserialize the method-call arguments; an unresolvable type aborts evaluation.","triggerScenarios":"An EvalDataParcel references a known type whose assembly path is missing or whose type name cannot be resolved in the current AppDomain/AssemblyLoadContext. The loop loads the assembly path only if non-empty and the file exists, then asks Type.GetType for the name.","commonSituations":"Cross-project or cross-version eval where the target type lives in an assembly not present at the recorded path. A renamed/moved type. A known-type assembly path that is empty (intended for system types) but the name does not resolve in mscorlib/System.","solutions":["Ensure all known-type assemblies are built and present at the paths recorded in the parcel.","Update the parcel's known type names to the current fully-qualified names after a rename/move.","For non-system types, supply a non-empty assembly path so the evaluator can load it before resolving the name."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"foreach (var name in knownTypeNames) { if (Type.GetType(name) == null) throw new InvalidOperationException($\"Unresolvable known type: {name}\"); }","typeGuard":null,"tryCatchPattern":"try { ExecuteExternalCode(parcel); }\ncatch (Exception ex) when (ex.Message.Contains(\"Could not find type\")) { Debug.LogError($\"Ensure known-type assemblies are present: {ex.Message}\"); }","preventionTips":["Build and ship all known-type assemblies at recorded paths","Update type names after renames","Supply non-empty assembly paths for non-system types"],"tags":["unity","editor","macros","reflection","type-resolution","assembly-loading"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}