EllanJiang/GameFramework · error · GameFrameworkException

Name is invalid.

Error message

Name is invalid.

What it means

The Resource class nested in ResourcePackVersionList validates the resource name in its constructor. Since every packed resource must be identified by name, a null or empty name makes the record meaningless, so a GameFrameworkException is thrown at construction time. This protects the in-memory pack version list from malformed entries.

Solutions

  1. Pass a valid non-empty resource name to the Resource constructor
  2. Regenerate the resource pack version list with the packaging pipeline
  3. Fix the deserialization/builder code so the name field is populated

Example fix

// before
new Resource(name: null, variant, extension, loadType, offset, length, hashCode, compressedLength, compressedHashCode);
// after
if (string.IsNullOrEmpty(name)) throw new ArgumentException("Resource name required");
new Resource(name, variant, extension, loadType, offset, length, hashCode, compressedLength, compressedHashCode);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(entry.Name)) { Log.Error("Pack resource entry missing name"); return; }

Type guard

bool IsValidResourceName(string n) => !string.IsNullOrEmpty(n);

Try / catch

try { var r = new Resource(name, ...); } catch (GameFrameworkException ex) when (ex.Message == "Name is invalid.") { Log.Error(ex, "Invalid pack resource entry"); }

Prevention

When it happens

Trigger: Constructing ResourcePackVersionList.Resource directly, or deserializing/parsing a resource-pack version list whose resource entry has a null or empty name field.

Common situations: A corrupted or hand-edited resource pack version file, a packaging tool that omitted the name, or partial binary data producing an empty string during deserialization.

Related errors


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

Appendix: source

Thrown at GameFramework/Resource/ResourcePackVersionList.Resource.cs:46

            private readonly int m_CompressedHashCode;

            /// <summary>
            /// 初始化资源的新实例。
            /// </summary>
            /// <param name="name">资源名称。</param>
            /// <param name="variant">资源变体名称。</param>
            /// <param name="extension">资源扩展名称。</param>
            /// <param name="loadType">资源加载方式。</param>
            /// <param name="offset">资源偏移。</param>
            /// <param name="length">资源长度。</param>
            /// <param name="hashCode">资源哈希值。</param>
            /// <param name="compressedLength">资源压缩后长度。</param>
            /// <param name="compressedHashCode">资源压缩后哈希值。</param>
            public Resource(string name, string variant, string extension, byte loadType, long offset, int length, int hashCode, int compressedLength, int compressedHashCode)
            {
                if (string.IsNullOrEmpty(name))
                {
                    throw new GameFrameworkException("Name is invalid.");
                }

                m_Name = name;
                m_Variant = variant;
                m_Extension = extension;
                m_LoadType = loadType;
                m_Offset = offset;
                m_Length = length;
                m_HashCode = hashCode;
                m_CompressedLength = compressedLength;
                m_CompressedHashCode = compressedHashCode;
            }

            /// <summary>
            /// 获取资源名称。
            /// </summary>
            public string Name
            {

View on GitHub (pinned to d0c010b051)