EllanJiang/GameFramework · error · GameFrameworkException

Resource group ' ' duplicated.

Error message

Resource group '{0}' duplicated.

What it means

ResourceGroupCollection rejects duplicate group references: while validating the array it compares each pair and throws GameFrameworkException("Resource group '{0}' duplicated.") when the same ResourceGroup instance appears more than once, because aggregating it twice would double-count resources and lengths.

Solutions

  1. Deduplicate the array before construction: groups.Distinct().ToArray().
  2. Track already-added group names when assembling the array from multiple sources.
  3. Log which group names were requested and verify each is only added once.

Example fix

// before
var groups = new ResourceGroup[] { rm.GetResourceGroup("UI"), rm.GetResourceGroup("UI") };
var col = new ResourceGroupCollection(groups, infos);
// after
var groups = new ResourceGroup[] { rm.GetResourceGroup("UI"), rm.GetResourceGroup("UI") }
    .Distinct().ToArray();
var col = new ResourceGroupCollection(groups, infos);
Defensive patterns

Strategy: validation

Validate before calling

groups = groups.Distinct().ToArray();
var col = new ResourceGroupCollection(groups, infos);

Type guard

bool NoDuplicates(ResourceGroup[] groups) => groups.Distinct().Count() == groups.Length;

Try / catch

try { var col = new ResourceGroupCollection(groups, infos); } catch (GameFrameworkException ex) { Log.Error(ex.Message); }

Prevention

When it happens

Trigger: Constructing the collection with the same ResourceGroup object appearing at two or more indices in the resourceGroups array.

Common situations: Adding a group by several overlapping name lists (e.g. "UI" requested both directly and via a parent config), or accumulating groups in a list without a Distinct() pass.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.ResourceGroupCollection.cs:54

                if (resourceInfos == null)
                {
                    throw new GameFrameworkException("Resource infos is invalid.");
                }

                int lastIndex = resourceGroups.Length - 1;
                for (int i = 0; i < lastIndex; i++)
                {
                    if (resourceGroups[i] == null)
                    {
                        throw new GameFrameworkException(Utility.Text.Format("Resource group index '{0}' is invalid.", i));
                    }

                    for (int j = i + 1; j < resourceGroups.Length; j++)
                    {
                        if (resourceGroups[i] == resourceGroups[j])
                        {
                            throw new GameFrameworkException(Utility.Text.Format("Resource group '{0}' duplicated.", resourceGroups[i].Name));
                        }
                    }
                }

                if (resourceGroups[lastIndex] == null)
                {
                    throw new GameFrameworkException(Utility.Text.Format("Resource group index '{0}' is invalid.", lastIndex));
                }

                m_ResourceGroups = resourceGroups;
                m_ResourceInfos = resourceInfos;
                m_ResourceNames = new HashSet<ResourceName>();
                m_TotalLength = 0L;
                m_TotalCompressedLength = 0L;

                List<ResourceName> cachedResourceNames = new List<ResourceName>();
                foreach (ResourceGroup resourceGroup in m_ResourceGroups)
                {

View on GitHub (pinned to d0c010b051)