EllanJiang/GameFramework · error · GameFrameworkException
Data table is invalid.
Error message
Data table is invalid.
What it means
DestroyDataTable<T>(IDataTable<T>) throws this when the dataTable argument is null. The manager cannot read the table's Name to build its lookup key, so it fails fast. This indicates the caller no longer holds a valid table reference.
Solutions
- Check the table reference for null before calling DestroyDataTable.
- Re-acquire the table with HasDataTable/GetDataTable to confirm it exists before destroying.
- Fix the code path that produced a null table reference (failed creation or prior destruction).
Example fix
// before
m_DataTableManager.DestroyDataTable(m_EnemyTable);
// after
if (m_EnemyTable != null)
{
m_DataTableManager.DestroyDataTable(m_EnemyTable);
m_EnemyTable = null;
} Defensive patterns
Strategy: type-guard
Validate before calling
if (dataTable == null) return false; // or log and skip
Type guard
static bool IsValidTable<T>(IDataTable<T> t) where T : IDataRow => t != null && !string.IsNullOrEmpty(t.Name);
Try / catch
try { manager.DestroyDataTable(table); }
catch (GameFrameworkException) { Log.Warning("Attempted to destroy a null data table"); } Prevention
- Null-out cached table references immediately after destroying
- Check HasDataTable before operating on cached references
- Avoid storing table references across scene loads
When it happens
Trigger: Calling DestroyDataTable(myTable) where myTable was already destroyed, never created, or an out/return value that was null; passing a cached table reference after table cleanup.
Common situations: Destroying tables on scene unload when a cached reference is stale; holding an IDataTable<T> from a manager that was already cleared; null-returning lookups passed straight to Destroy.
Related errors
- Data row type is invalid.
- Data row type ' ' is invalid.
- Results is invalid.
- You must set resource manager first.
- Debugger window is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/174eb3561b5404d6.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/DataTable/DataTableManager.cs:459
if (!typeof(IDataRow).IsAssignableFrom(dataRowType))
{
throw new GameFrameworkException(Utility.Text.Format("Data row type '{0}' is invalid.", dataRowType.FullName));
}
return InternalDestroyDataTable(new TypeNamePair(dataRowType, name));
}
/// <summary>
/// 销毁数据表。
/// </summary>
/// <typeparam name="T">数据表行的类型。</typeparam>
/// <param name="dataTable">要销毁的数据表。</param>
/// <returns>是否销毁数据表成功。</returns>
public bool DestroyDataTable<T>(IDataTable<T> dataTable) where T : IDataRow
{
if (dataTable == null)
{
throw new GameFrameworkException("Data table is invalid.");
}
return InternalDestroyDataTable(new TypeNamePair(typeof(T), dataTable.Name));
}
/// <summary>
/// 销毁数据表。
/// </summary>
/// <param name="dataTable">要销毁的数据表。</param>
/// <returns>是否销毁数据表成功。</returns>
public bool DestroyDataTable(DataTableBase dataTable)
{
if (dataTable == null)
{
throw new GameFrameworkException("Data table is invalid.");
}
return InternalDestroyDataTable(new TypeNamePair(dataTable.Type, dataTable.Name));View on GitHub (pinned to d0c010b051)