egametang/ET · error · Exception

type:{type} definition could not be found. Please try `Hybri

Error message

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

What it means

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.

Source

Thrown at Packages/cn.etetet.hybridclr/Scripts/Editor/Share/ABI/TypeCreator.cs:71

                case ElementType.String:
                case ElementType.Ptr:
                case ElementType.ByRef:
                case ElementType.Class:
                case ElementType.Array:
                case ElementType.SZArray:
                case ElementType.FnPtr:
                case ElementType.Object:
                case ElementType.Module:
                case ElementType.Var:
                case ElementType.MVar:
                    return TypeInfo.s_u;
                case ElementType.TypedByRef: return TypeInfo.s_typedByRef;
                case ElementType.ValueType:
                {
                    TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDef();
                    if (typeDef == null)
                    {
                        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");
                    }
                    if (typeDef.IsEnum)
                    {
                        return CreateTypeInfo(typeDef.GetEnumUnderlyingType());
                    }
                    return CreateValueType(type);
                }
                case ElementType.GenericInst:
                {
                    GenericInstSig gis = (GenericInstSig)type;
                    if (!gis.GenericType.IsValueType)
                    {
                        return TypeInfo.s_u;
                    }
                    TypeDef typeDef = gis.GenericType.ToTypeDefOrRef().ResolveTypeDef();
                    if (typeDef.IsEnum)
                    {
                        return CreateTypeInfo(typeDef.GetEnumUnderlyingType());

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Run HybridCLR > Generate > LinkXml, then build the project once to generate the AOT DLLs, then re-run the bridge generation.
  2. Verify that the assembly containing the unresolved value type is included in the AOT reference assemblies and the link.xml.
  3. Check HybridCLRSettings for correct AOT DLL output paths (SettingsUtil.GeneratedAssemblyDir or similar).
  4. If the type is from a third-party assembly, ensure it is referenced and available in the build pipeline.

Example fix

// workflow fix — no code change, follow this sequence in the Unity menu:
// 1. HybridCLR > Generate > LinkXml
// 2. File > Build And Run (generates AOT DLLs)
// 3. HybridCLR > Generate > All (regenerates bridge functions)

// before — type resolution fails during generation
// TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDef(); // returns null

// after — ensure AOT DLLs exist before generation
if (typeDef == null)
{
    Debug.LogError($"Cannot resolve {type}. Run Generate > LinkXml, build once, then regenerate.");
    return TypeInfo.s_u; // fallback rather than crash
}
Defensive patterns

Strategy: validation

Validate before calling

// Before calling CreateTypeInfo, verify AOT DLLs exist
string aotDir = SettingsUtil.GeneratedAssemblyDir; // or the configured AOT output path
if (!Directory.Exists(aotDir) || Directory.GetFiles(aotDir, "*.dll").Length == 0)
{
    Debug.LogError("AOT DLLs not found. Run HybridCLR > Generate > LinkXml, then Build once, then Generate > All.");
    return;
}

Try / catch

try
{
    var typeInfo = typeCreator.CreateTypeInfo(typeSig);
}
catch (Exception ex) when (ex.Message.Contains("definition could not be found"))
{
    Debug.LogError($"Type '{typeSig}' could not be resolved. " +
        "Run HybridCLR > Generate > LinkXml, build once to generate AOT DLLs, then regenerate bridge functions.");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/af607f31ffa9b354. Report an issue: GitHub.