EllanJiang/GameFramework · error · GameFrameworkException

Config helper is invalid.

Error message

Config helper is invalid.

What it means

ConfigManager.SetConfigHelper stores the global config helper (interface bridge between the framework and the host engine, e.g. Unity's ConfigHelper). A null helper would break all config loading later, so it is rejected at assignment time.

Solutions

  1. Create/attach the helper before registration (e.g. new DefaultConfigHelper() or AddComponent<ConfigHelper>())
  2. Verify the helper field/property is initialized in the component's Awake
  3. Assert non-null at the call site to catch the misconfiguration early

Example fix

// before
m_ConfigManager.SetConfigHelper(m_ConfigHelper); // null
// after
m_ConfigHelper = m_ConfigHelper ?? new DefaultConfigHelper();
m_ConfigManager.SetConfigHelper(m_ConfigHelper);
Defensive patterns

Strategy: type-guard

Validate before calling

if (configHelper == null) { configHelper = new DefaultConfigHelper(); }
configManager.SetConfigHelper(configHelper);

Type guard

bool Ready(IConfigHelper h) => h != null;

Try / catch

try { configManager.SetConfigHelper(helper); }
catch (GameFrameworkException ex) { Debug.LogError($"Config helper setup failed: {ex.Message}"); }

Prevention

When it happens

Trigger: Calling SetConfigHelper(null) or passing a helper field that was never assigned, e.g. forgetting to add the ConfigHelper component to a Unity GameObject before initialization.

Common situations: GameFramework component setup ordering issues: the helper MonoBehaviour isn't attached/created yet; custom helper class deleted during refactor leaving a null field.

Related errors


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

Appendix: source

Thrown at GameFramework/Config/ConfigManager.cs:157

        /// <summary>
        /// 设置全局配置数据提供者辅助器。
        /// </summary>
        /// <param name="dataProviderHelper">全局配置数据提供者辅助器。</param>
        public void SetDataProviderHelper(IDataProviderHelper<IConfigManager> dataProviderHelper)
        {
            m_DataProvider.SetDataProviderHelper(dataProviderHelper);
        }

        /// <summary>
        /// 设置全局配置辅助器。
        /// </summary>
        /// <param name="configHelper">全局配置辅助器。</param>
        public void SetConfigHelper(IConfigHelper configHelper)
        {
            if (configHelper == null)
            {
                throw new GameFrameworkException("Config helper is invalid.");
            }

            m_ConfigHelper = configHelper;
        }

        /// <summary>
        /// 确保二进制流缓存分配足够大小的内存并缓存。
        /// </summary>
        /// <param name="ensureSize">要确保二进制流缓存分配内存的大小。</param>
        public void EnsureCachedBytesSize(int ensureSize)
        {
            DataProvider<IConfigManager>.EnsureCachedBytesSize(ensureSize);
        }

        /// <summary>
        /// 释放缓存的二进制流。
        /// </summary>
        public void FreeCachedBytes()

View on GitHub (pinned to d0c010b051)