EllanJiang/GameFramework · error · GameFrameworkException

Resource pack length is invalid.

Error message

Resource pack length is invalid.

What it means

ApplyResources throws this when the version list's Offset + Length does not equal the actual pack file length. The resource pack version list records where the embedded data sits in the file; a mismatch means the file is truncated, extended, or from a different build.

Solutions

  1. Re-download the resource pack and verify its byte length against the server manifest before applying
  2. Regenerate the resource pack so the version list offsets match the file contents
  3. Ensure binary-safe transfer (no text-mode or encoding transformations) when copying the pack

Example fix

// before
resourceManager.ApplyResources("pack.dat"); // file truncated, length mismatch
// after
if (new FileInfo("pack.dat").Length == manifest.ExpectedLength) resourceManager.ApplyResources("pack.dat");
else RetryDownload("pack.dat", manifest.ExpectedLength);
Defensive patterns

Strategy: validation

Validate before calling

if (new FileInfo(packPath).Length != manifest.ExpectedLength) { Redownload(packPath); return; }

Try / catch

try { resourceManager.ApplyResources(packPath); } catch (GameFrameworkException ex) { Log.Error("Resource pack length mismatch, redownloading: " + ex.Message); RedownloadPack(); }

Prevention

When it happens

Trigger: Applying a partially downloaded/truncated pack file; appending or modifying pack bytes after generation; pack file and version list built by mismatched pipeline versions.

Common situations: Network download interrupted and file saved anyway; file transfer in text mode corrupting bytes; manually merging or editing pack files; server serving an outdated pack.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.ResourceUpdater.cs:355

                try
                {
                    long length = 0L;
                    ResourcePackVersionList versionList = default(ResourcePackVersionList);
                    using (FileStream fileStream = new FileStream(resourcePackPath, FileMode.Open, FileAccess.Read))
                    {
                        length = fileStream.Length;
                        versionList = m_ResourceManager.m_ResourcePackVersionListSerializer.Deserialize(fileStream);
                    }

                    if (!versionList.IsValid)
                    {
                        throw new GameFrameworkException("Deserialize resource pack version list failure.");
                    }

                    if (versionList.Offset + versionList.Length != length)
                    {
                        throw new GameFrameworkException("Resource pack length is invalid.");
                    }

                    m_ApplyingResourcePackPath = resourcePackPath;
                    m_ApplyingResourcePackStream = new FileStream(resourcePackPath, FileMode.Open, FileAccess.Read);
                    m_ApplyingResourcePackStream.Position = versionList.Offset;
                    m_FailureFlag = false;

                    long totalLength = 0L;
                    ResourcePackVersionList.Resource[] resources = versionList.GetResources();
                    foreach (ResourcePackVersionList.Resource resource in resources)
                    {
                        ResourceName resourceName = new ResourceName(resource.Name, resource.Variant, resource.Extension);
                        UpdateInfo updateInfo = null;
                        if (!m_UpdateCandidateInfo.TryGetValue(resourceName, out updateInfo))
                        {
                            continue;
                        }

View on GitHub (pinned to d0c010b051)