EllanJiang/GameFramework · error · GameFrameworkException

Resource manager is invalid.

Error message

Resource manager is invalid.

What it means

Thrown by DataTableManager.SetResourceManager when the supplied IResourceManager is null. The data table module depends on the resource manager to load table assets, so it refuses a null dependency during initialization.

Solutions

  1. Create and set the IResourceManager before SetResourceManager is called.
  2. Assert the component chain in startup: resource manager, then data table manager wiring.
  3. Check for typos/null returns when obtaining the manager from a service locator.

Example fix

// before
dataTableManager.SetResourceManager(null);
// after
m_ResourceManager = new ResourceManager();
m_ResourceManager.Initialize(...);
dataTableManager.SetResourceManager(m_ResourceManager);
Defensive patterns

Strategy: type-guard

Validate before calling

if (m_ResourceManager != null) dataTableManager.SetResourceManager(m_ResourceManager);

Type guard

bool IsValidResourceManager(IResourceManager rm) => rm != null;

Try / catch

try { dataTableManager.SetResourceManager(rm); } catch (GameFrameworkException ex) when (ex.Message.Contains("Resource manager")) { /* initialize resource manager first */ }

Prevention

When it happens

Trigger: Calling SetResourceManager(null), or passing a resourceManager field/property that has not been initialized yet in the game framework startup sequence.

Common situations: Framework components wired in the wrong order; DI container returning null; refactor renamed the resource manager instance before assignment.

Related errors


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

Appendix: source

Thrown at GameFramework/DataTable/DataTableManager.cs:87

        internal override void Shutdown()
        {
            foreach (KeyValuePair<TypeNamePair, DataTableBase> dataTable in m_DataTables)
            {
                dataTable.Value.Shutdown();
            }

            m_DataTables.Clear();
        }

        /// <summary>
        /// 设置资源管理器。
        /// </summary>
        /// <param name="resourceManager">资源管理器。</param>
        public void SetResourceManager(IResourceManager resourceManager)
        {
            if (resourceManager == null)
            {
                throw new GameFrameworkException("Resource manager is invalid.");
            }

            m_ResourceManager = resourceManager;
        }

        /// <summary>
        /// 设置数据表数据提供者辅助器。
        /// </summary>
        /// <param name="dataProviderHelper">数据表数据提供者辅助器。</param>
        public void SetDataProviderHelper(IDataProviderHelper<DataTableBase> dataProviderHelper)
        {
            if (dataProviderHelper == null)
            {
                throw new GameFrameworkException("Data provider helper is invalid.");
            }

            m_DataProviderHelper = dataProviderHelper;
        }

View on GitHub (pinned to d0c010b051)