EllanJiang/GameFramework · error · GameFrameworkException
Owner is invalid.
Error message
Owner is invalid.
What it means
DataProviderCreator.Create<T>() throws GameFrameworkException('Owner is invalid.') when the owner argument passed to create a new DataProvider<T> is null. The owner is the object the data provider will belong to, and a null owner would make the provider unusable, so the factory rejects it eagerly. This is a fail-fast argument validation at the very start of Create.
Solutions
- Pass a non-null owner instance to Create<T>, e.g. the game object/component that will own the data provider
- Check the owner for null before calling Create and initialize it (in Awake/Start or constructor) if it is lazily assigned
- Verify any lookup used to obtain the owner (GetComponent, table, service locator) actually succeeded instead of returning null
Example fix
// before
IDataProvider<Player> provider = DataProviderCreator.Create<Player>(null, resourceManager, helper);
// after
if (player == null) { throw new InvalidOperationException("Player owner not initialized"); }
IDataProvider<Player> provider = DataProviderCreator.Create<Player>(player, resourceManager, helper); Defensive patterns
Strategy: validation
Validate before calling
if (owner == null) throw new ArgumentNullException(nameof(owner)); DataProviderCreator.Create<T>(owner, resourceManager, helper);
Type guard
bool IsValidOwner<T>(T owner) => owner != null;
Try / catch
try
{
var provider = DataProviderCreator.Create<T>(owner, resourceManager, helper);
}
catch (GameFrameworkException ex) when (ex.Message == "Owner is invalid.")
{
// log and fail fast: owner must be initialized before creating a provider
} Prevention
- Assign owner references in Awake/constructor before any provider creation
- Assert owner != null at the top of factory/helper methods that call Create
- Avoid obtaining the owner from lookups that can silently return null without checking
When it happens
Trigger: Calling GameFramework.DataProvider.DataProviderCreator.Create<T>(owner, resourceManager, dataProviderHelper) with owner == null. Typically happens when the caller's own owner field/reference has not been assigned yet (e.g. a component property accessed before initialization) or a static owner variable is still null.
Common situations: Calling Create from a script whose MonoBehaviour/owner reference is not yet wired in Awake; passing the result of a lookup (GetComponent, dictionary) that returned null; refactoring changed initialization order so Create runs before the owner is assigned.
Related errors
- Data provider helper is invalid.
- Resource manager is invalid.
- Type is invalid.
- Event is invalid.
- Data row type is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/baff0e94f3c474af.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Base/DataProvider/DataProviderCreator.cs:58
/// <typeparam name="T">数据提供者的持有者的类型。</typeparam>
public static void FreeCachedBytes<T>()
{
DataProvider<T>.FreeCachedBytes();
}
/// <summary>
/// 创建数据提供者。
/// </summary>
/// <typeparam name="T">数据提供者的持有者的类型。</typeparam>
/// <param name="owner">数据提供者的持有者。</param>
/// <param name="resourceManager">资源管理器。</param>
/// <param name="dataProviderHelper">数据提供者辅助器。</param>
/// <returns>创建的数据提供者。</returns>
public static IDataProvider<T> Create<T>(T owner, IResourceManager resourceManager, IDataProviderHelper<T> dataProviderHelper)
{
if (owner == null)
{
throw new GameFrameworkException("Owner is invalid.");
}
if (resourceManager == null)
{
throw new GameFrameworkException("Resource manager is invalid.");
}
if (dataProviderHelper == null)
{
throw new GameFrameworkException("Data provider helper is invalid.");
}
DataProvider<T> dataProvider = new DataProvider<T>(owner);
dataProvider.SetResourceManager(resourceManager);
dataProvider.SetDataProviderHelper(dataProviderHelper);
return dataProvider;
}
}View on GitHub (pinned to d0c010b051)