EllanJiang/GameFramework · error · GameFrameworkException
Data row type is invalid.
Error message
Data row type is invalid.
What it means
HasDataTable(Type) throws this when the dataRowType argument is null. The DataTableManager keys its tables by row type (TypeNamePair), so a null type cannot be looked up and is rejected immediately before any table lookup happens.
Solutions
- Pass a concrete row type literal, e.g. HasDataTable(typeof(MyDataRow)).
- If the type comes from a variable, check it for null before calling (if (dataRowType == null) return false;).
- If the type is resolved from a string via reflection, verify the string matches the full class name and that the assembly is loaded.
- Wrap in try-catch (GameFrameworkException) if the type source is dynamic and cannot be validated upfront.
Example fix
// before
dataTableManager.HasDataTable(rowType);
// after
if (rowType == null) throw new ArgumentException("dataRowType must be a type implementing IDataRow");
bool exists = dataTableManager.HasDataTable(rowType); Defensive patterns
Strategy: validation
Validate before calling
if (dataRowType == null) throw new ArgumentException("dataRowType must not be null");
dataTableManager.HasDataTable(dataRowType); Type guard
bool IsValidRowType(Type t) => t != null && typeof(IDataRow).IsAssignableFrom(t);
Try / catch
try { dataTableManager.HasDataTable(dataRowType); }
catch (GameFrameworkException ex) { Log.Error("Invalid data row type: {0}", ex.Message); } Prevention
- Always pass typeof(T) literals instead of Type variables when the row type is known at compile time.
- Null-check dynamically resolved Types before any DataTableManager call.
- Centralize row-type resolution in one helper that validates against IDataRow.
When it happens
Trigger: Calling dataTableManager.HasDataTable(null) — typically a variable holding a Type that was never assigned, or a GetType()/typeof() expression that resolved to null via reflection.
Common situations: Reflection-driven table registration where Activator or config supplies the row type; a field of type Type left uninitialized; refactorings that renamed row classes and broke a string-to-Type lookup returning null.
Related errors
- Results is invalid.
- Owner is invalid.
- Resource manager is invalid.
- Data provider helper is invalid.
- Type is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/c7e3750f01a774a3.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/DataTable/DataTableManager.cs:157
/// 是否存在数据表。
/// </summary>
/// <typeparam name="T">数据表行的类型。</typeparam>
/// <returns>是否存在数据表。</returns>
public bool HasDataTable<T>() where T : IDataRow
{
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
{View on GitHub (pinned to d0c010b051)