{"record":{"id":"ae3fb85572f22fe8","repo":"EllanJiang/GameFramework","slug":"download-manager-is-invalid-resourcemanager","errorCode":null,"errorMessage":"Download manager is invalid.","messagePattern":"Download manager is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.VersionListProcessor.cs","lineNumber":68,"sourceCode":"            /// </summary>\n            public void Shutdown()\n            {\n                if (m_DownloadManager != null)\n                {\n                    m_DownloadManager.DownloadSuccess -= OnDownloadSuccess;\n                    m_DownloadManager.DownloadFailure -= OnDownloadFailure;\n                }\n            }\n\n            /// <summary>\n            /// 设置下载管理器。\n            /// </summary>\n            /// <param name=\"downloadManager\">下载管理器。</param>\n            public void SetDownloadManager(IDownloadManager downloadManager)\n            {\n                if (downloadManager == null)\n                {\n                    throw new GameFrameworkException(\"Download manager is invalid.\");\n                }\n\n                m_DownloadManager = downloadManager;\n                m_DownloadManager.DownloadSuccess += OnDownloadSuccess;\n                m_DownloadManager.DownloadFailure += OnDownloadFailure;\n            }\n\n            /// <summary>\n            /// 检查版本资源列表。\n            /// </summary>\n            /// <param name=\"latestInternalResourceVersion\">最新的内部资源版本号。</param>\n            /// <returns>检查版本资源列表结果。</returns>\n            public CheckVersionListResult CheckVersionList(int latestInternalResourceVersion)\n            {\n                if (string.IsNullOrEmpty(m_ResourceManager.m_ReadWritePath))\n                {\n                    throw new GameFrameworkException(\"Read-write path is invalid.\");\n                }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.VersionListProcessor.cs#L50-L86","documentation":"VersionListProcessor.SetDownloadManager throws this when the downloadManager argument is null. The processor subscribes to the manager's DownloadSuccess/DownloadFailure events to drive version-list updates, so a null manager would break its whole dependency wiring.","triggerScenarios":"Passing null (or an uninitialized IDownloadManager field) to SetDownloadManager during resource-system setup.","commonSituations":"Initialization order issues where the DownloadManager component hasn't been created/obtained yet; a null return from a service locator/framework GetComponent call being passed straight through.","solutions":["Create and initialize the DownloadManager before calling SetDownloadManager.","Ensure the object passed implements IDownloadManager and is non-null (check your GetComponent/dependency lookup).","Reorder bootstrap so DownloadManager setup precedes VersionListProcessor setup."],"exampleFix":"// before\nm_ResourceManager.SetDownloadManager(m_DownloadManager); // null: not yet created\n// after\nm_DownloadManager = GameEntry.GetComponent<DownloadManager>();\nif (m_DownloadManager != null)\n{\n    m_ResourceManager.SetDownloadManager(m_DownloadManager);\n}","handlingStrategy":"type-guard","validationCode":"// C#\nIDownloadManager dm = GameEntry.GetComponent<DownloadManager>();\nif (dm == null)\n{\n    throw new InvalidOperationException(\"DownloadManager not initialized before SetDownloadManager\");\n}\nm_ResourceManager.SetDownloadManager(dm);","typeGuard":"// C#\nbool IsValidDownloadManager(IDownloadManager dm) => dm != null;","tryCatchPattern":null,"preventionTips":["Initialize the DownloadManager component before wiring it into the resource system.","Null-check dependency lookups instead of passing results straight through.","Keep a single ordered bootstrap method: helpers, then download manager, then version processing."],"tags":["gameframework","version-list","null-argument","initialization-order"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}