stride3d/stride · error · InvalidOperationException
Two bundles with name
Error message
Two bundles with name {0} found What it means
ObjectNode.Add supports collections and dictionaries; when the node's Descriptor is neither a CollectionDescriptor nor a DictionaryDescriptor, the value cannot be added and a NotSupportedException is thrown. This is a guard against calling Add on node types (plain objects, sets, unsupported collections) that have no defined add semantics.
Solutions
- Check the node's Descriptor type before calling Add: only call Add when descriptor is CollectionDescriptor or DictionaryDescriptor.
- For sets, use the set-specific API (SetDescriptor) instead of Add.
- For fixed-size structures like arrays, replace the whole value via Update/SetValue rather than adding items.
Example fix
// before
node.Add(newItem, NodeIndex.Empty);
// after
if (node.Descriptor is CollectionDescriptor || node.Descriptor is DictionaryDescriptor)
node.Add(newItem, NodeIndex.Empty); Defensive patterns
Strategy: validation
Validate before calling
bool canAdd = node.Descriptor is CollectionDescriptor or DictionaryDescriptor;
if (!canAdd) throw new InvalidOperationException($"Cannot Add on node of type {node.Descriptor?.GetType().Name}"); Type guard
bool IsAddableCollection(ObjectNode node) => node.Descriptor is CollectionDescriptor or DictionaryDescriptor;
Try / catch
try { node.Add(value, index); }
catch (NotSupportedException ex) { /* fall back to whole-value update or surface unsupported-collection state */ } Prevention
- Check Descriptor type before mutating collection nodes
- Never call Add on set- or array-backed nodes
- Centralize node mutation in helpers that dispatch on descriptor kind
When it happens
Trigger: Calling ObjectNode.Add(value, index) on a node whose Descriptor is not a CollectionDescriptor or DictionaryDescriptor — e.g. a set, an array, a non-collection property, or a custom collection the descriptor system does not recognize.
Common situations: Binding a UI editor or property grid to a node backed by a set or fixed-size array and then invoking Add from 'add item' UI commands; reflection/undo-redo code assuming every collection node supports Add.
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
- content reference(s) were not rooted (see errors above)…
- Cyclic dependency found, involving
- Unable to set the node value, the collection is unsupported
- Could not find dependency
- Could not find asset
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/e7fed2cd1cdccc87.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.AssetCompiler/BundlePacker.cs:87
pathSelector.Paths[i] = "/" + assetNamespace + path;
}
}
}
bundles.AddRange(project.Bundles);
}
var databaseFileProvider = new DatabaseFileProvider(objDatabase.ContentIndexMap, objDatabase);
// Fail early with a clear error if any reference was left bare instead of rooted.
ValidateReferenceRooting(logger, databaseFileProvider, assetNamespaces);
// Pass1: Create ResolvedBundle from user Bundle
var resolvedBundles = new Dictionary<string, ResolvedBundle>();
foreach (var bundle in bundles)
{
if (resolvedBundles.ContainsKey(bundle.Name))
{
throw new InvalidOperationException(string.Format("Two bundles with name {0} found", bundle.Name));
}
resolvedBundles.Add(bundle.Name, new ResolvedBundle(bundle));
}
// Pass2: Enumerate all assets which directly or indirectly belong to an bundle
var bundleAssets = new HashSet<string>();
foreach (var bundle in resolvedBundles)
{
// For each project, we apply asset selectors of current bundle
// This will give us a list of "root assets".
foreach (var assetSelector in bundle.Value.Source.Selectors)
{
foreach (var assetLocation in assetSelector.Select(packageSession, objDatabase.ContentIndexMap))
{
bundle.Value.AssetUrls.Add(assetLocation);
}View on GitHub (pinned to 96fad776d2)