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 in the UIElementFromSystemLibrary constructor when the given id cannot be found in the system UI library asset's Hierarchy.Parts. The constructor needs the part to determine Type and Category, so a missing id makes the object impossible to construct.
Solutions
- Use a valid id that exists in the current system library (enumerate library.Asset.Hierarchy.Parts to pick one).
- Restore/upgrade the library asset so the expected id exists.
- Guard with TryGetValue before constructing and handle the missing-element case (skip, log, or prompt the user).
Example fix
// before
var vm = new UIElementFromSystemLibrary(systemLibrary, oldId);
// after
if (!systemLibrary.Asset.Hierarchy.Parts.TryGetValue(oldId, out var design))
return null; // or prompt user to re-pick
var vm = new UIElementFromSystemLibrary(systemLibrary, oldId); Defensive patterns
Strategy: validation
Validate before calling
bool exists = library?.Asset?.Hierarchy?.Parts.TryGetValue(id, out _) == true;
Type guard
static bool SystemLibraryContains(UILibraryViewModel library, Guid id) => library?.Asset?.Hierarchy?.Parts.ContainsKey(id) ?? false;
Try / catch
try { var vm = new UIElementFromSystemLibrary(library, id); } catch (InvalidOperationException ex) { /* fall back to re-picking element */ } Prevention
- Enumerate library.Asset.Hierarchy.Parts to obtain valid ids instead of hardcoding them.
- Re-check system library ids after engine upgrades.
- Handle deserialized legacy ids by mapping them to current library entries.
When it happens
Trigger: Constructing UIElementFromSystemLibrary(library, id) with an id that is not a key of library.Asset.Hierarchy.Parts — e.g. an id from a different library version or a typo'd/removed system element id.
Common situations: Engine upgrade where built-in library element ids changed; hand-written editor scripts referencing removed system UI elements; deserialized editor state holding ids from an older Stride 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/f3ced18b7127bb23.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/ViewModels/UIElementFromSystemLibrary.cs:31
using Stride.UI;
using Stride.Core.Presentation.ViewModels;
namespace Stride.Assets.Presentation.AssetEditors.UIEditor.ViewModels
{
internal sealed class UIElementFromSystemLibrary : ViewModelBase, IUIElementFactory
{
private readonly UILibraryViewModel library;
private readonly Guid id;
public UIElementFromSystemLibrary([NotNull] IViewModelServiceProvider serviceProvider, [NotNull] UILibraryViewModel library, Guid id)
: base(serviceProvider)
{
this.library = library;
this.id = id;
UIElementDesign element;
if (!library.Asset.Hierarchy.Parts.TryGetValue(id, out element))
throw new InvalidOperationException("The corresponding UI element could not be found in the library.");
Type = element.UIElement.GetType();
Category = TypeDescriptorFactory.Default.AttributeRegistry.GetAttribute<Core.DisplayAttribute>(Type)?.Category ?? "Misc.";
}
public string Name => Type.Name;
public Type Type { get; }
public string Category { get; }
[NotNull]
public AssetCompositeHierarchyData<UIElementDesign, UIElement> Create(UIAssetBase targetAsset)
{
// Create a clone without linking to the library
var flags = SubHierarchyCloneFlags.GenerateNewIdsForIdentifiableObjects | SubHierarchyCloneFlags.RemoveOverrides;
var clonedHierarchy = UIAssetPropertyGraph.CloneSubHierarchies(library.Session.AssetNodeContainer, library.Asset, id.Yield(), flags, out Dictionary<Guid, Guid> _);
foreach (var part in clonedHierarchy.Parts.Values)View on GitHub (pinned to 96fad776d2)