stride3d/stride · error · ArgumentNullException

ArgumentNullException: pasteResultItem

Error message

ArgumentNullException: pasteResultItem

What it means

Argument-null validation guard in UIHierarchyPasteProcessor.Paste: the pasteResultItem parameter is null when the paste operation is invoked. The processor needs a valid paste item to build the pasted UI element hierarchy; a null item means no content was actually pasted, so the operation is rejected immediately.

Solutions

  1. Ensure the copy/clone step produced a non-null IPasteItem before invoking Paste
  2. Guard the call site: skip paste (or show a message) when the paste item is null
  3. If using the built-in pipeline, confirm the clipboard actually contains copied UI elements before triggering paste

Example fix

// before
await processor.Paste(copiedItem, graph, ref accessor, ref container); // copiedItem may be null
// after
if (copiedItem != null)
    await processor.Paste(copiedItem, graph, ref accessor, ref container);
Defensive patterns

Strategy: type-guard

Validate before calling

if (pasteItem == null) return; // nothing to paste

Type guard

bool CanPaste(IPasteItem item) => item?.Data != null;

Try / catch

try { await processor.Paste(item, graph, ref accessor, ref container); }
catch (ArgumentNullException) { // clipboard was empty; show 'nothing to paste' feedback
}

Prevention

When it happens

Trigger: Invoking the paste pipeline on a UI asset with a null IPasteItem — typically a null result from an upstream copy/clone step passed straight into Paste.

Common situations: Custom copy-paste processors or editor automation that call Paste directly with the result of a failed/absent copy operation; clipboard API returning null on empty paste buffer.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/89d21ad926fd8117. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/ViewModel/CopyPasteProcessors/UIHierarchyPasteProcessor.cs:23

using System.Threading.Tasks;
using Stride.Core.Assets;
using Stride.Core.Assets.Editor.Services;
using Stride.Core.Assets.Editor.ViewModel.CopyPasteProcessors;
using Stride.Core.Assets.Quantum;
using Stride.Core;
using Stride.Core.Quantum;
using Stride.Assets.Quantum;
using Stride.Assets.UI;
using Stride.UI;
using Stride.UI.Panels;

namespace Stride.Assets.Presentation.ViewModel.CopyPasteProcessors
{
    public class UIHierarchyPasteProcessor : AssetCompositeHierarchyPasteProcessor<UIElementDesign, UIElement>
    {
        public override Task Paste(IPasteItem pasteResultItem, AssetPropertyGraph assetPropertyGraph, ref NodeAccessor nodeAccessor, ref PropertyContainer container)
        {
            if (pasteResultItem == null) throw new ArgumentNullException(nameof(pasteResultItem));

            var propertyGraph = (UIAssetPropertyGraph)assetPropertyGraph;
            var parentElement = nodeAccessor.RetrieveValue() as UIElement;

            // 1. try to paste as hierarchy
            var hierarchy = pasteResultItem.Data as AssetCompositeHierarchyData<UIElementDesign, UIElement>;
            if (hierarchy != null)
            {
                // Note: check that adding or inserting is supported is done in CanPaste()
                foreach (var rootUIElement in hierarchy.RootParts)
                {
                    var asset = (UIAssetBase)propertyGraph.Asset;
                    var insertIndex = parentElement == null ? asset.Hierarchy.RootParts.Count : ((parentElement as Panel)?.Children.Count ?? 0);
                    propertyGraph.AddPartToAsset(hierarchy.Parts, hierarchy.Parts[rootUIElement.Id], parentElement, insertIndex);
                }
            }
            return Task.CompletedTask;
        }

View on GitHub (pinned to 96fad776d2)