stride3d/stride · error · ArgumentNullException

views

Error message

views

What it means

The params-array overload of SetOutput throws ArgumentNullException("views") when the caller passes a null array. Unlike the single-texture overload, it does not reject an empty array here — only a null array reference triggers this error.

Solutions

  1. Initialize the Texture[] array before calling SetOutput
  2. Pass at least one texture to the params overload
  3. Guard: if (views == null) return;

Example fix

// before
Texture[] outputs = null;
effect.SetOutput(outputs);
// after
Texture[] outputs = new Texture[] { renderTarget };
effect.SetOutput(outputs);
Defensive patterns

Strategy: validation

Validate before calling

if (views == null || views.Length == 0) throw new InvalidOperationException("At least one output texture required");

Type guard

bool IsValidOutputs(Texture[] views) => views != null && views.All(v => v != null);

Try / catch

try { effect.SetOutput(views); } catch (ArgumentNullException) { /* supply initialized array */ }

Prevention

When it happens

Trigger: Calling effect.SetOutput() with an explicitly null Texture[] (note: effect.SetOutput() with zero arguments passes an empty array, not null, and does NOT throw this).

Common situations: Storing output views in a field initialized later, then invoking SetOutput(views) with the still-null field in C#; passing an expression that evaluates to null due to a failed texture array allocation.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs:121

        /// <summary>
        /// Sets the render target output.
        /// </summary>
        /// <param name="view">The render target output view.</param>
        /// <exception cref="System.ArgumentNullException">view</exception>
        public void SetOutput(Texture view)
        {
            if (view == null) throw new ArgumentNullException("view");

            SetOutputInternal(view);
        }

        /// <summary>
        /// Sets the render target outputs.
        /// </summary>
        /// <param name="views">The render target output views.</param>
        public void SetOutput(params Texture[] views)
        {
            if (views == null) throw new ArgumentNullException("views");

            SetOutputInternal(views);
        }

        /// <summary>
        /// Sets the render target output.
        /// </summary>
        /// <param name="depthStencilView">The depth stencil output view.</param>
        /// <param name="renderTargetView">The render target output view.</param>
        public void SetDepthOutput(Texture depthStencilView, Texture renderTargetView)
        {
            outputDepthStencilView = depthStencilView;
            outputRenderTargetView = renderTargetView;
            outputRenderTargetViews = null;
        }

        /// <summary>
        /// Sets the render target outputs.

View on GitHub (pinned to 96fad776d2)