{"record":{"id":"ad4faa3cd43a358b","repo":"EllanJiang/GameFramework","slug":"you-must-set-download-manager-first-resourcemanager","errorCode":null,"errorMessage":"You must set download manager first.","messagePattern":"You must set download manager first\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.VersionListProcessor.cs","lineNumber":139,"sourceCode":"                {\n                    return CheckVersionListResult.NeedUpdate;\n                }\n\n                return CheckVersionListResult.Updated;\n            }\n\n            /// <summary>\n            /// 更新版本资源列表。\n            /// </summary>\n            /// <param name=\"versionListLength\">版本资源列表大小。</param>\n            /// <param name=\"versionListHashCode\">版本资源列表哈希值。</param>\n            /// <param name=\"versionListCompressedLength\">版本资源列表压缩后大小。</param>\n            /// <param name=\"versionListCompressedHashCode\">版本资源列表压缩后哈希值。</param>\n            public void UpdateVersionList(int versionListLength, int versionListHashCode, int versionListCompressedLength, int versionListCompressedHashCode)\n            {\n                if (m_DownloadManager == null)\n                {\n                    throw new GameFrameworkException(\"You must set download manager first.\");\n                }\n\n                m_VersionListLength = versionListLength;\n                m_VersionListHashCode = versionListHashCode;\n                m_VersionListCompressedLength = versionListCompressedLength;\n                m_VersionListCompressedHashCode = versionListCompressedHashCode;\n                string localVersionListFilePath = Utility.Path.GetRegularPath(Path.Combine(m_ResourceManager.m_ReadWritePath, RemoteVersionListFileName));\n                int dotPosition = RemoteVersionListFileName.LastIndexOf('.');\n                string latestVersionListFullNameWithCrc32 = Utility.Text.Format(\"{0}.{2:x8}.{1}\", RemoteVersionListFileName.Substring(0, dotPosition), RemoteVersionListFileName.Substring(dotPosition + 1), m_VersionListHashCode);\n                m_DownloadManager.AddDownload(localVersionListFilePath, Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_UpdatePrefixUri, latestVersionListFullNameWithCrc32)), this);\n            }\n\n            private void OnDownloadSuccess(object sender, DownloadSuccessEventArgs e)\n            {\n                VersionListProcessor versionListProcessor = e.UserData as VersionListProcessor;\n                if (versionListProcessor == null || versionListProcessor != this)\n                {\n                    return;","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.VersionListProcessor.cs#L121-L157","documentation":"VersionListProcessor.UpdateVersionList throws this when its download manager reference is null, meaning SetDownloadManager was never called (or was called with a value that failed its own null check). The updater must schedule a download of the new version list, so a download manager is mandatory.","triggerScenarios":"Calling UpdateVersionList after the check-versions server response indicates an update is needed, but the game never wired the download manager into the resource system.","commonSituations":"Partial initialization: version checking wired up but download manager setup skipped or failed; SetDownloadManager called on a different processor instance; exception during earlier setup swallowed, leaving m_DownloadManager null.","solutions":["Call ResourceManager.SetDownloadManager(downloadManager) during bootstrap, before any version-list update can occur.","Check your init sequence: SetResourceHelper -> SetDownloadManager -> check versions -> update.","Verify SetDownloadManager succeeded (no earlier exceptions) and targets the same ResourceManager instance."],"exampleFix":"// before\n// UpdateVersionList called after CheckVersionList(NeedUpdate) but download manager never set\n// after (bootstrap)\nm_ResourceManager.SetDownloadManager(GameEntry.GetComponent<DownloadManager>());\n// then CheckVersionList / UpdateVersionList flow is safe","handlingStrategy":"try-catch","validationCode":"// C#\n// bootstrap, before any update flow can run:\nm_ResourceManager.SetDownloadManager(GameEntry.GetComponent<DownloadManager>());","typeGuard":null,"tryCatchPattern":"// C#\ntry\n{\n    m_ResourceManager.UpdateVersionList(length, hashCode, compressedLength, compressedHashCode);\n}\ncatch (GameFrameworkException ex) when (ex.Message.Contains(\"set download manager\"))\n{\n    // initialization bug: wire SetDownloadManager in bootstrap, then retry\n}","preventionTips":["Treat SetDownloadManager as a mandatory step of resource-system bootstrap.","Order init: SetResourceHelper -> SetDownloadManager -> check versions -> update.","Don't swallow exceptions during setup — a swallowed failure can leave the processor unwired."],"tags":["gameframework","version-list","missing-dependency","initialization-order"],"backgroundTag":"missing-dependency","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"}