stride3d/stride · error · InvalidOperationException
Cannot change the parent of an AssetMountPointViewModel
Error message
Cannot change the parent of an AssetMountPointViewModel
What it means
MountPointViewModel represents the root mount point of a package in the asset tree; its Parent is defined as always null. The Parent setter throws InvalidOperationException because a mount point can never be attached to another directory.
Solutions
- Never set Parent on a MountPointViewModel; treat it as a fixed root
- Check the node type before attempting reparent operations
- Operate on DirectoryViewModel children instead of the mount point itself
Example fix
// before
mountPoint.Parent = targetFolder;
// after
if (mountPoint is DirectoryViewModel dir) { dir.Parent = targetFolder; } Defensive patterns
Strategy: type-guard
Validate before calling
if (node is MountPointViewModel) throw new ArgumentException("Mount points cannot be reparented"); Type guard
bool CanSetParent(DirectoryBaseViewModel n) => n is DirectoryViewModel;
Try / catch
try { node.Parent = target; } catch (InvalidOperationException) { /* mount point: parent is fixed null */ } Prevention
- Treat mount points as fixed roots
- Type-check before tree mutations
- Skip mount points in drag-drop handlers
When it happens
Trigger: Assigning the Parent property of a MountPointViewModel, or calling DirectoryBaseViewModel.SetParent with a mount point as the target.
Common situations: Generic tree/drag-drop code that moves any DirectoryBaseViewModel node, accidentally picking a package's mount point as the drag source or drop child.
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
- Cannot delete a MountPointViewModel
- The name of a package reference cannot be set
- A PackageViewModel cannot contain two isntances of…
- A session is already open in this instance.
- A transaction failed to be created.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/e68c65feac378b42.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Core.Assets.Editor/ViewModel/MountPointViewModel.cs:20
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
using Stride.Core.Presentation.Dirtiables;
namespace Stride.Core.Assets.Editor.ViewModel
{
public abstract class MountPointViewModel : DirectoryBaseViewModel
{
protected MountPointViewModel(PackageViewModel package)
: base(package.Session)
{
Package = package;
}
public override string Path => string.Empty;
public override DirectoryBaseViewModel Parent { get { return null; } set { throw new InvalidOperationException("Cannot change the parent of an AssetMountPointViewModel"); } }
public override MountPointViewModel Root => this;
public override PackageViewModel Package { get; }
/// <inheritdoc/>
public override string TypeDisplayName => "Mount Point";
/// <inheritdoc/>
public override IEnumerable<IDirtiable> Dirtiables => base.Dirtiables.Concat(Package.Dirtiables);
public IReadOnlyCollection<DirectoryBaseViewModel> GetDirectoryHierarchy()
{
var hierarchy = new List<DirectoryBaseViewModel>();
GetDirectoryHierarchy(hierarchy);
return hierarchy;
}
View on GitHub (pinned to 96fad776d2)