EllanJiang/GameFramework · error · GameFrameworkException

Data row type ' ' is invalid.

Error message

Data row type '{0}' is invalid.

What it means

HasDataTable(Type) throws this when dataRowType is not null but does not implement the IDataRow interface. DataTableManager only manages tables whose row types implement IDataRow, so any other Type is rejected before the internal lookup.

Solutions

  1. Make the row class implement IDataRow (it must have a public parameterless Id property of type int per the interface contract).
  2. Pass the actual row data type, not a container or base class.
  3. Verify the class implements the IDataRow from the same GameFramework assembly being used at runtime (avoid duplicate interface definitions across assemblies).

Example fix

// before
public class MyDataRow { public int Id { get; set; } }
dataTableManager.HasDataTable(typeof(MyDataRow));
// after
public class MyDataRow : IDataRow { public int Id { get; set; } }
dataTableManager.HasDataTable(typeof(MyDataRow));
Defensive patterns

Strategy: type-guard

Validate before calling

if (dataRowType == null || !typeof(IDataRow).IsAssignableFrom(dataRowType))
    throw new ArgumentException("dataRowType must implement IDataRow: " + dataRowType?.FullName);

Type guard

bool IsValidRowType(Type t) => t != null && typeof(IDataRow).IsAssignableFrom(t);

Try / catch

try { dataTableManager.HasDataTable(dataRowType); }
catch (GameFrameworkException ex) { Log.Error("Row type '{0}' does not implement IDataRow.", dataRowType?.FullName); }

Prevention

When it happens

Trigger: Calling HasDataTable(typeof(SomeClass)) where SomeClass does not implement IDataRow — e.g. passing a plain data class, a ViewModel, or a row type from an older/incompatible GameFramework version where the interface was named differently.

Common situations: Migrating tables from another framework; copy-pasting a data class that forgot the IDataRow interface; passing typeof(DataTableBase) or a generic wrapper type instead of the actual row type.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/8ac6ec0e30ad98e5. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/DataTable/DataTableManager.cs:162

        {
            return InternalHasDataTable(new TypeNamePair(typeof(T)));
        }

        /// <summary>
        /// 是否存在数据表。
        /// </summary>
        /// <param name="dataRowType">数据表行的类型。</param>
        /// <returns>是否存在数据表。</returns>
        public bool HasDataTable(Type dataRowType)
        {
            if (dataRowType == null)
            {
                throw new GameFrameworkException("Data row type is invalid.");
            }

            if (!typeof(IDataRow).IsAssignableFrom(dataRowType))
            {
                throw new GameFrameworkException(Utility.Text.Format("Data row type '{0}' is invalid.", dataRowType.FullName));
            }

            return InternalHasDataTable(new TypeNamePair(dataRowType));
        }

        /// <summary>
        /// 是否存在数据表。
        /// </summary>
        /// <typeparam name="T">数据表行的类型。</typeparam>
        /// <param name="name">数据表名称。</param>
        /// <returns>是否存在数据表。</returns>
        public bool HasDataTable<T>(string name) where T : IDataRow
        {
            return InternalHasDataTable(new TypeNamePair(typeof(T), name));
        }

        /// <summary>
        /// 是否存在数据表。

View on GitHub (pinned to d0c010b051)