dotnet/wpf · error · ArgumentException

SR.Effect_No_InputSource

Error message

SR.Effect_No_InputSource

What it means

BitmapEffect.GetOutput(input) was called with a BitmapEffectInput whose Input property is null — no source bitmap was set. The method first null-checks the argument itself, then checks input.Input; when the source was never assigned it throws ArgumentException with SR.Effect_No_InputSource for the 'input' parameter.

Solutions

  1. Set input.Input to a BitmapSource before calling GetOutput
  2. Validate input.Input != null before invoking GetOutput
  3. Check why the bound/assigned source is null (binding errors, failed image load)
  4. If 'use the whole visual context' was intended, read the context source instead of leaving Input unset

Example fix

// before
var input = new BitmapEffectInput();
var output = effect.GetOutput(input); // throws: Input not set

// after
var input = new BitmapEffectInput { Input = sourceBitmap };
var output = effect.GetOutput(input);
Defensive patterns

Strategy: validation

Validate before calling

if (input == null) throw new ArgumentNullException(nameof(input));
if (input.Input == null)
    throw new ArgumentException("BitmapEffectInput.Input must be set before GetOutput", nameof(input));
var output = effect.GetOutput(input);

Try / catch

try { var output = effect.GetOutput(input); }
catch (ArgumentException ex) when (ex.ParamName == "input")
{
    // assign a real source and retry
}

Prevention

When it happens

Trigger: Calling GetOutput(new BitmapEffectInput()) or with an input created without setting .Input; reading Output before assigning the effect's Input in a render pipeline.

Common situations: Custom effect evaluation code that forgot Input assignment; data-binding that failed to deliver the source; reordering code so GetOutput runs before Input is set.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/9273393c46f5af2e. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/BitmapEffect.cs:97

                 SafeHandle/* IMILBitmapEffectPrimitive */ innerObject)
        {
        }

        #endregion

        #region Public Methods
        /// <summary>
        /// This returns the output at index 0
        /// </summary>
        [Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]
        public BitmapSource GetOutput(BitmapEffectInput input)
        {
            ArgumentNullException.ThrowIfNull(input);

            // if we don't have the input set, we should not be calling the output property
            if (input.Input == null)
            {
                throw new ArgumentException(SR.Effect_No_InputSource, nameof(input));
            }

            if (input.Input == BitmapEffectInput.ContextInputSource)
            {
                throw new InvalidOperationException(SR.Format(SR.Effect_No_ContextInputSource, null));
            }

            return input.Input.Clone();
        }
        #endregion

        #region Internal Methods

        /// <summary>
        /// True if the effect can be emulated by the Effect pipeline. Derived classes 
        /// can override this method to indicate that they can be emulated using the ImageEffect
        /// pipeline. If a derived class returns true it needs to also implement the GetEmulatingImageEffect
        /// property to provide an emulating ImageEffect.

View on GitHub (pinned to 81131a70a4)