dotnet/wpf · error · ArgumentException
SR.Format(SR.FrugalList_TargetMapCannotHoldAllData…
Error message
SR.Format(SR.FrugalList_TargetMapCannotHoldAllData, oldList.ToString(), this.ToString())
What it means
FrugalList Promote throws ArgumentException (message resource FrugalList_TargetMapCannotHoldAllData) when promoting a smaller-capacity frugal list into a larger one that is itself already full — the target map cannot hold all the data from the old list. This is an internal capacity invariant violation discovered during list promotion (called from Clone).
Solutions
- Promote to a capacity class at least large enough for oldList.Count plus existing target entries
- Ensure Promote is only called on targets with sufficient remaining capacity — check _count before promoting
- If hit through normal Add growth, this indicates an internal invariant bug; capture the list counts and file a WPF issue
Example fix
// before if (oldList.Count > SIZE) Promote(oldList); // target too small // after if (Count + oldList.Count <= SIZE) Promote(oldList); else Promote(new LargerList(this));
Defensive patterns
Strategy: try-catch
Validate before calling
if (target.Count + source.Count > target.Capacity) target = new LargerFrugalList(target);
Try / catch
try { target.Promote(oldList); }
catch (ArgumentException ex) when (ex.Message.Contains("CannotHoldAllData")) { /* promote to a larger capacity class instead */ } Prevention
- Always promote to a capacity class strictly larger than the source
- Track counts so target has room for all incoming entries
- Treat this throw as an internal invariant bug and report it
When it happens
Trigger: Clone (or Promote) is invoked to move a SingleItemList/ThreeItemList's contents into a larger frugal list whose current count plus the source count exceeds the target's fixed capacity — the target has no free slot for every old entry.
Common situations: Growth of frugal collections (used heavily by WPF dependency-property value stores) when many values are stored; a bug or corrupted count in the store can make the promotion target smaller than the source data.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- SR.TableCollectionNotEnoughCapacity
- Collection_CopyTo_ArrayCannotBeMultidimensional
- Collection_CopyTo_ArrayCannotBeMultidimensional
- Collection_CopyTo_IndexGreaterThanOrEqualToArrayLength
- Collection_CopyTo_IndexGreaterThanOrEqualToArrayLength
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/8e1a2f2230d4e066.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/Shared/MS/Utility/FrugalList.cs:331
--_count;
}
public override T EntryAt(int index)
{
return _loneEntry;
}
public override void Promote(FrugalListBase<T> oldList)
{
if (oldList.Count == SIZE)
{
SetCount(SIZE);
SetAt(0, oldList.EntryAt(0));
}
else
{
// this list is smaller than oldList
throw new ArgumentException(SR.Format(SR.FrugalList_TargetMapCannotHoldAllData, oldList.ToString(), this.ToString()), nameof(oldList));
}
}
// Class specific implementation to avoid virtual method calls and additional logic
public void Promote(SingleItemList<T> oldList)
{
SetCount(oldList.Count);
SetAt(0, oldList.EntryAt(0));
}
public override T[] ToArray()
{
T[] array = new T[SIZE];
array[0] = _loneEntry;
return array;
}
public override void CopyTo(T[] array, int index)View on GitHub (pinned to 81131a70a4)