{"record":{"id":"af607f31ffa9b354","repo":"egametang/ET","slug":"type-type-definition-could-not-be-found-please","errorCode":null,"errorMessage":"type:{type} definition could not be found. Please try `HybridCLR/Genergate/LinkXml`, then Build once to generate the AOT dll, and then regenerate the bridge function","messagePattern":"type:(.+?) definition could not be found\\. Please try `HybridCLR/Genergate/LinkXml`, then Build once to generate the AOT dll, and then regenerate the bridge function","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.hybridclr/Scripts/Editor/Share/ABI/TypeCreator.cs","lineNumber":71,"sourceCode":"                case ElementType.String:\n                case ElementType.Ptr:\n                case ElementType.ByRef:\n                case ElementType.Class:\n                case ElementType.Array:\n                case ElementType.SZArray:\n                case ElementType.FnPtr:\n                case ElementType.Object:\n                case ElementType.Module:\n                case ElementType.Var:\n                case ElementType.MVar:\n                    return TypeInfo.s_u;\n                case ElementType.TypedByRef: return TypeInfo.s_typedByRef;\n                case ElementType.ValueType:\n                {\n                    TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDef();\n                    if (typeDef == null)\n                    {\n                        throw new Exception($\"type:{type} definition could not be found. Please try `HybridCLR/Genergate/LinkXml`, then Build once to generate the AOT dll, and then regenerate the bridge function\");\n                    }\n                    if (typeDef.IsEnum)\n                    {\n                        return CreateTypeInfo(typeDef.GetEnumUnderlyingType());\n                    }\n                    return CreateValueType(type);\n                }\n                case ElementType.GenericInst:\n                {\n                    GenericInstSig gis = (GenericInstSig)type;\n                    if (!gis.GenericType.IsValueType)\n                    {\n                        return TypeInfo.s_u;\n                    }\n                    TypeDef typeDef = gis.GenericType.ToTypeDefOrRef().ResolveTypeDef();\n                    if (typeDef.IsEnum)\n                    {\n                        return CreateTypeInfo(typeDef.GetEnumUnderlyingType());","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.hybridclr/Scripts/Editor/Share/ABI/TypeCreator.cs#L53-L89","documentation":"Thrown by TypeCreator.CreateTypeInfo0 when resolving a ValueType's TypeDef via dnlib returns null. During HybridCLR bridge/method-adapter generation, each parameter type must be resolved to its full metadata definition. If the assembly containing the value type has not been loaded or its metadata is unavailable, ResolveTypeDef fails and the generator cannot compute the type's ABI layout.","triggerScenarios":"CreateTypeInfo is called during bridge-function or method-adapter generation. For a ValueType element, it calls type.ToTypeDefOrRef().ResolveTypeDef(). If the type's defining assembly is not in the resolver's search path (typically because the AOT/reference DLLs have not been generated yet), the resolution returns null.","commonSituations":"Running HybridCLR generation (e.g. Generate/MethodBridge or Generate/All) before building the project at least once so the AOT DLLs exist; a value type lives in an assembly not included in the link.xml or AOT reference set; the AOT DLL path is misconfigured in HybridCLRSettings; upgrading HybridCLR without re-running Generate/LinkXml.","solutions":["Run HybridCLR > Generate > LinkXml, then build the project once to generate the AOT DLLs, then re-run the bridge generation.","Verify that the assembly containing the unresolved value type is included in the AOT reference assemblies and the link.xml.","Check HybridCLRSettings for correct AOT DLL output paths (SettingsUtil.GeneratedAssemblyDir or similar).","If the type is from a third-party assembly, ensure it is referenced and available in the build pipeline."],"exampleFix":"// workflow fix — no code change, follow this sequence in the Unity menu:\n// 1. HybridCLR > Generate > LinkXml\n// 2. File > Build And Run (generates AOT DLLs)\n// 3. HybridCLR > Generate > All (regenerates bridge functions)\n\n// before — type resolution fails during generation\n// TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDef(); // returns null\n\n// after — ensure AOT DLLs exist before generation\nif (typeDef == null)\n{\n    Debug.LogError($\"Cannot resolve {type}. Run Generate > LinkXml, build once, then regenerate.\");\n    return TypeInfo.s_u; // fallback rather than crash\n}","handlingStrategy":"validation","validationCode":"// Before calling CreateTypeInfo, verify AOT DLLs exist\nstring aotDir = SettingsUtil.GeneratedAssemblyDir; // or the configured AOT output path\nif (!Directory.Exists(aotDir) || Directory.GetFiles(aotDir, \"*.dll\").Length == 0)\n{\n    Debug.LogError(\"AOT DLLs not found. Run HybridCLR > Generate > LinkXml, then Build once, then Generate > All.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var typeInfo = typeCreator.CreateTypeInfo(typeSig);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"definition could not be found\"))\n{\n    Debug.LogError($\"Type '{typeSig}' could not be resolved. \" +\n        \"Run HybridCLR > Generate > LinkXml, build once to generate AOT DLLs, then regenerate bridge functions.\");\n}","preventionTips":["Always run the full generation sequence: LinkXml > Build > Generate/All, in that order.","After upgrading HybridCLR or adding new value types, re-run Generate/All.","Verify that assemblies containing value types are included in the AOT reference set and link.xml.","Check HybridCLRSettings for correct AOT assembly paths before generation."],"tags":["hybridclr","type-resolution","aot-dll","bridge-generation","dnlib","metadata"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}