stride3d/stride · error · InvalidOperationException
The corresponding UI Element could not be found in the…
Error message
The corresponding UI Element could not be found in the library
What it means
Thrown by UIElementFromLibrary.Create when the Id of the library-sourced UI element no longer exists in the referenced UI library asset's Hierarchy.Parts. Create is supposed to instantiate a copy of an element stored in a UI library; if the part keyed by Id is absent there is nothing to instantiate.
Solutions
- Re-create the reference so it points at an Id that currently exists in the library asset.
- Open the UI library asset and re-add/restore the missing element, or pick a different library element in the editor.
- Verify library.Asset.Hierarchy.Parts.ContainsKey(Id) before calling Create and fall back to user selection if false.
Example fix
// before
var element = uiElementFromLibrary.Create(targetAsset);
// after
if (!uiElementFromLibrary.library.Asset.Hierarchy.Parts.ContainsKey(uiElementFromLibrary.Id))
throw new InvalidOperationException($"Library element {uiElementFromLibrary.Id} missing from {uiElementFromLibrary.library.Url}");
var element = uiElementFromLibrary.Create(targetAsset); Defensive patterns
Strategy: validation
Validate before calling
bool exists = uiElementFromLibrary.library?.Asset?.Hierarchy?.Parts.ContainsKey(uiElementFromLibrary.Id) == true;
Type guard
static bool LibraryElementExists(UIElementFromLibrary e) => e?.library?.Asset?.Hierarchy?.Parts.ContainsKey(e.Id) ?? false;
Try / catch
try { var el = fromLibrary.Create(targetAsset); } catch (InvalidOperationException ex) { /* re-pick library element */ } Prevention
- Re-validate library references after editing the library asset.
- Avoid persisting raw element ids across library versions; re-resolve by name/category.
- Wrap Create calls with existence checks when automating editor tasks.
When it happens
Trigger: Creating an element instance from a UIElementFromLibrary whose Id was removed or regenerated in the source UILibraryAsset (e.g. library edited/re-saved after the reference was captured, or the Id belongs to a different library asset).
Common situations: Stale references after the library asset was edited and a UI element deleted; merging library assets so IDs changed; copy-pasting elements that reference an old library version.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- The corresponding UI element could not be found in the…
- The given parentId does not correspond to any existing part.
- The given assetSidePart.Id does not correspond to any…
- The given element is not a child of this panel.
- Can't change the name of a UILibrary object.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/c54329f982229c4b.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/ViewModels/UIElementFromLibrary.cs:38
: base(serviceProvider)
{
this.library = library;
Id = id;
var node = library.Session.AssetNodeContainer.GetNode(library.Asset)[nameof(UILibraryAsset.PublicUIElements)];
nameBinding = new MemberGraphNodeBinding<Dictionary<Guid, string>>(node, nameof(Name), OnPropertyChanging, OnPropertyChanged, library.UndoRedoService);
}
public Guid Id { get; }
public string Name => nameBinding.Value.ContainsKey(Id) ? nameBinding.Value[Id] : "(undefined)";
public string Category => library.Url;
public AssetCompositeHierarchyData<UIElementDesign, UIElement> Create(UIAssetBase targetAsset)
{
if (!library.Asset.Hierarchy.Parts.ContainsKey(Id))
throw new InvalidOperationException("The corresponding UI Element could not be found in the library");
var asset = (UILibraryAsset)library.Asset;
return asset.CreateElementInstance(targetAsset, library.Url, Id);
}
}
}
View on GitHub (pinned to 96fad776d2)