stride3d/stride · error · ArgumentNullException
ArgumentNullException: child
Error message
ArgumentNullException: child
What it means
SceneViewModel.CanBeParentOf checks whether one scene can be a parent of another. The child parameter is mandatory; passing null throws ArgumentNullException(nameof(child)) since the parentability check cannot be evaluated for a missing scene.
Solutions
- Check the dragged/target SceneViewModel is non-null before calling CanBeParentOf
- Resolve the SceneViewModel from the drag payload first; abort the drag if resolution fails
- Change the call site to return early (treat null child as not parentable) instead of querying
Example fix
// before bool ok = scene.CanBeParentOf(draggedScene, out msg); // after bool ok = draggedScene != null && scene.CanBeParentOf(draggedScene, out msg);
Defensive patterns
Strategy: type-guard
Validate before calling
if (child == null) { message = "No target scene"; return false; } Type guard
bool CanEvaluate(SceneViewModel child) => child != null;
Try / catch
try { return scene.CanBeParentOf(child, out msg); }
catch (ArgumentNullException) { return false; // null child can never be parented
} Prevention
- Resolve drag payloads to SceneViewModel before computing parent validity
- Treat null child references as 'not parentable' early in drag/drop handlers
- Null-check references after scene renames/moves that may invalidate cached view models
When it happens
Trigger: Calling CanBeParentOf with a null SceneViewModel child — e.g. drag-and-drop handlers computing parent validity before resolving the dragged item, or filtering scenes where a reference was not yet resolved.
Common situations: Custom editor plugins implementing drag/drop reparenting that call CanBeParentOf with a null candidate; UI bindings passing null while a drag operation is in flight.
Related errors
- ArgumentNullException: pasteResultItem
- Custom strides is not supported with packed PixelFormats
- Model property is unset.
- parent cannot be null
- Parent cannot be null
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/68633740526796d2.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/ViewModel/SceneViewModel.cs:72
[CanBeNull]
public SceneViewModel Parent { get { return parent; } private set { SetValueUncancellable(ref parent, value, ParentPropertyChanged); } }
[NotNull]
internal ICommandBase SetAsDefaultCommand { get; }
/// <summary>
/// Checks whether this scene can be a parent of the provided <paramref name="child"/> scene.
/// </summary>
/// <param name="child">The potential child of this scene.</param>
/// <param name="message">A message providing more details on why this scene can -or cannot- be a parent.</param>
/// <param name="checkSameParent">
/// <c>true</c> to also check if this scene is already a parent of the provided <paramref name="child"/> scene; otherwise, <c>false</c>.
/// The default is <c>false</c>.
/// </param>
/// <returns><c>true</c> if this scene can be of parent of the provided <paramref name="child"/> scene; otherwise, <c>false</c>.</returns>
public bool CanBeParentOf([NotNull] SceneViewModel child, [NotNull] out string message, bool checkSameParent = false)
{
if (child == null) throw new ArgumentNullException(nameof(child));
if (child == this)
{
message = "Can't be a parent of itself";
return false;
}
if (checkSameParent && child.Parent == this)
{
message = "Scene already has this parent";
return false;
}
var scene = Parent;
while (scene != null)
{
if (scene == child)
{
message = "Circular scene hierarchy";
return false;View on GitHub (pinned to 96fad776d2)