{"record":{"id":"56ede15eff78b6dd","repo":"EllanJiang/GameFramework","slug":"resource-helper-is-invalid-resourcemanager-resourceiniter","errorCode":null,"errorMessage":"Resource helper is invalid.","messagePattern":"Resource helper is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"critical","filePath":"GameFramework/Resource/ResourceManager.ResourceIniter.cs","lineNumber":56,"sourceCode":"            }\n\n            /// <summary>\n            /// 关闭并清理资源初始化器。\n            /// </summary>\n            public void Shutdown()\n            {\n            }\n\n            /// <summary>\n            /// 初始化资源。\n            /// </summary>\n            public void InitResources(string currentVariant)\n            {\n                m_CurrentVariant = currentVariant;\n\n                if (m_ResourceManager.m_ResourceHelper == null)\n                {\n                    throw new GameFrameworkException(\"Resource helper is invalid.\");\n                }\n\n                if (string.IsNullOrEmpty(m_ResourceManager.m_ReadOnlyPath))\n                {\n                    throw new GameFrameworkException(\"Read-only path is invalid.\");\n                }\n\n                m_ResourceManager.m_ResourceHelper.LoadBytes(Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_ReadOnlyPath, RemoteVersionListFileName)), new LoadBytesCallbacks(OnLoadPackageVersionListSuccess, OnLoadPackageVersionListFailure), null);\n            }\n\n            private void OnLoadPackageVersionListSuccess(string fileUri, byte[] bytes, float duration, object userData)\n            {\n                MemoryStream memoryStream = null;\n                try\n                {\n                    memoryStream = new MemoryStream(bytes, false);\n                    PackageVersionList versionList = m_ResourceManager.m_PackageVersionListSerializer.Deserialize(memoryStream);\n                    if (!versionList.IsValid)","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceIniter.cs#L38-L74","documentation":"ResourceManager.ResourceIniter.InitResources starts the resource initialization pipeline and first verifies the framework's dependencies. It throws GameFrameworkException(\"Resource helper is invalid.\") when m_ResourceManager.m_ResourceHelper is null, because the initialization cannot read the resource package without a resource helper (IResourceHelper).","triggerScenarios":"Calling InitResources before ResourceManager's resource helper was set — i.e. SetResourceHelper was never called or the helper failed to be created via the game framework's initializer.","commonSituations":"Skipping Framework entries: custom bootstrap that bypasses GameFramework's component initialization and calls InitResources directly; a custom resource-helper type that failed to instantiate (exception during creation leaves the helper null); wrong initialization order where InitResources runs before SetResourceHelper.","solutions":["Call ResourceManager.SetResourceHelper(new DefaultResourceHelper()) (or your custom helper) before InitResources.","If using Unity GameFramework components, ensure the BaseComponent/ResourceComponent initialization flow ran completely before triggering initialization.","Check for exceptions/failed instantiation in your custom IResourceHelper creation code."],"exampleFix":"// before\nresourceComponent.InitResources(currentVariant); // helper never set\n// after\nresourceComponent.SetResourceHelper(new DefaultResourceHelper());\nresourceComponent.InitResources(currentVariant);","handlingStrategy":"validation","validationCode":"if (resourceComponent.ResourceHelper == null)\n    resourceComponent.SetResourceHelper(new DefaultResourceHelper());\nresourceComponent.InitResources(currentVariant);","typeGuard":"bool HelperReady(GameFramework.Resource.ResourceManager rm) => rm != null && rm.ResourceHelper != null;","tryCatchPattern":"try { resourceComponent.InitResources(variant); } catch (GameFrameworkException ex) { Log.Fatal($\"InitResources failed: {ex.Message}\"); }","preventionTips":["Always call SetResourceHelper before InitResources","Follow the standard GameFramework component initialization order","Verify custom IResourceHelper instantiation succeeds and log creation failures"],"tags":["csharp","initialization","missing-dependency","resource-management"],"backgroundTag":"missing-dependency","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"}