stride3d/stride · error · NotSupportedException
is not a supported mode.
Error message
is not a supported mode.
What it means
SortedList's internal enumerators use an EnumeratorMode (KEY_MODE/VALUE_MODE/ENTRY_MODE). Reading Current falls through to a default case that throws NotSupportedException when the mode is none of the known values. This is effectively an internal invariant violation: user code should never be able to set the mode directly.
Solutions
- Stop capturing/serializing enumerator objects; create a fresh enumerator via GetEnumerator() each time you iterate
- Verify no reflection or derived-class code writes to the enumerator's mode field
- Iterate with foreach or an explicitly typed interface (IDictionaryEnumerator/IEnumerator) so the correct mode is set by the library
Example fix
// before
var e = ((IEnumerable)sortedList).GetEnumerator();
Serialize(e); // corrupts internal mode
// after
foreach (DictionaryEntry entry in sortedList) { /* use entry */ } Defensive patterns
Strategy: try-catch
Validate before calling
bool isEnumeratorValid(IEnumerator e) => e != null && (e.GetType().Name != "SortedListEnumerator" || IsKnownMode(e));
Try / catch
try { var cur = enumerator.Current; } catch (NotSupportedException) { enumerator = sortedList.GetEnumerator(); } Prevention
- Never serialize, cache, or reflectively manipulate SortedList enumerators
- Create a new enumerator per iteration pass
- Iterate via foreach rather than raw IEnumerator
When it happens
Trigger: Reading Current from a SortedList enumerator whose _mode field holds a value outside KEY_MODE/VALUE_MODE/ENTRY_MODE — typically only via reflection, serialization of the enumerator, or memory/state corruption.
Common situations: Debugging tools or tests poking at enumerator internals; deserializing a captured enumerator object; custom derived code that assigned an invalid mode.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Collection was modified after the enumerator was…
- attempt to modify a key
- This operation is not supported by the source tracker.
- InvalidOperationException
- The collection was modified after the enumerator was…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b6e3c4a073313109.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core/Collections/SortedList.cs:785
public object Current
{
get
{
if (invalid || pos >= size || pos == -1)
throw new InvalidOperationException(xstr);
switch (mode)
{
case EnumeratorMode.KEY_MODE:
return currentKey;
case EnumeratorMode.VALUE_MODE:
return currentValue;
case EnumeratorMode.ENTRY_MODE:
return this.Entry;
default:
throw new NotSupportedException(mode + " is not a supported mode.");
}
}
}
// ICloneable
public object Clone()
{
var e = new DictionaryEnumerator(host, mode);
e.stamp = stamp;
e.pos = pos;
e.size = size;
e.currentKey = currentKey;
e.currentValue = currentValue;
e.invalid = invalid;
return e;
}
}View on GitHub (pinned to 96fad776d2)