{"record":{"id":"376b7d2894069692","repo":"EllanJiang/GameFramework","slug":"resource-manager-is-invalid-datatablemanager","errorCode":null,"errorMessage":"Resource manager is invalid.","messagePattern":"Resource manager is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/DataTable/DataTableManager.cs","lineNumber":87,"sourceCode":"        internal override void Shutdown()\n        {\n            foreach (KeyValuePair<TypeNamePair, DataTableBase> dataTable in m_DataTables)\n            {\n                dataTable.Value.Shutdown();\n            }\n\n            m_DataTables.Clear();\n        }\n\n        /// <summary>\n        /// 设置资源管理器。\n        /// </summary>\n        /// <param name=\"resourceManager\">资源管理器。</param>\n        public void SetResourceManager(IResourceManager resourceManager)\n        {\n            if (resourceManager == null)\n            {\n                throw new GameFrameworkException(\"Resource manager is invalid.\");\n            }\n\n            m_ResourceManager = resourceManager;\n        }\n\n        /// <summary>\n        /// 设置数据表数据提供者辅助器。\n        /// </summary>\n        /// <param name=\"dataProviderHelper\">数据表数据提供者辅助器。</param>\n        public void SetDataProviderHelper(IDataProviderHelper<DataTableBase> dataProviderHelper)\n        {\n            if (dataProviderHelper == null)\n            {\n                throw new GameFrameworkException(\"Data provider helper is invalid.\");\n            }\n\n            m_DataProviderHelper = dataProviderHelper;\n        }","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/DataTable/DataTableManager.cs#L69-L105","documentation":"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.","triggerScenarios":"Calling SetResourceManager(null), or passing a resourceManager field/property that has not been initialized yet in the game framework startup sequence.","commonSituations":"Framework components wired in the wrong order; DI container returning null; refactor renamed the resource manager instance before assignment.","solutions":["Create and set the IResourceManager before SetResourceManager is called.","Assert the component chain in startup: resource manager, then data table manager wiring.","Check for typos/null returns when obtaining the manager from a service locator."],"exampleFix":"// before\ndataTableManager.SetResourceManager(null);\n// after\nm_ResourceManager = new ResourceManager();\nm_ResourceManager.Initialize(...);\ndataTableManager.SetResourceManager(m_ResourceManager);","handlingStrategy":"type-guard","validationCode":"if (m_ResourceManager != null) dataTableManager.SetResourceManager(m_ResourceManager);","typeGuard":"bool IsValidResourceManager(IResourceManager rm) => rm != null;","tryCatchPattern":"try { dataTableManager.SetResourceManager(rm); } catch (GameFrameworkException ex) when (ex.Message.Contains(\"Resource manager\")) { /* initialize resource manager first */ }","preventionTips":["Initialize the resource manager before wiring the data table manager","Follow the documented framework startup order","Assert dependencies non-null at startup"],"tags":["csharp","datatable","initialization","null-argument"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}