dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'source11')

Error message

Value cannot be null. (Parameter 'source11')

What it means

The public CombineLatest overload for 11 sources throws ArgumentNullException when the source11 argument is null. Rx.NET validates all source sequences and the result selector eagerly before subscribing, because a null source would otherwise fail only later with an obscure NullReferenceException inside the query pipeline.

Solutions

  1. Ensure the argument passed as source11 is a non-null IObservable before calling CombineLatest
  2. If the source may be absent, substitute Observable.Empty<TSource11>() (noting CombineLatest then produces no output until all sources emit) or Observable.Return(defaultValue)
  3. Check where the null originates (uninitialized field, failed lookup) and fix the producer
  4. Wrap the call in ArgumentNullException handling only at the boundary where you cannot guarantee inputs

Example fix

// before
Observable.CombineLatest(a, b, c, d, e, f, g, h, i, j, maybeEleventh, (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) => Combine(x11));
// after
var s11 = maybeEleventh ?? Observable.Empty<T11>();
Observable.CombineLatest(a, b, c, d, e, f, g, h, i, j, s11, (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) => Combine(x11));
Defensive patterns

Strategy: validation

Validate before calling

if (source11 is null) throw new ArgumentNullException(nameof(source11));
// or coalesce:
// source11 ??= Observable.Empty<T11>();

Type guard

static bool IsNotNullSource<T>(IObservable<T> s) => s is not null;

Try / catch

try
{
    combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, selector);
}
catch (ArgumentNullException ex) when (ex.ParamName == "source11")
{
    // log and substitute a fallback observable or rethrow with context
}

Prevention

When it happens

Trigger: Calling Observable.CombineLatest(s1..s11, resultSelector) with a null 11th argument — e.g. a variable holding an IObservable that was never assigned, a dictionary lookup that returned null, or a conditional source that defaulted to null.

Common situations: Building a chain of observables from optional dependencies or config-driven sources where the last source is conditionally created; passing the result of a factory method that returns null instead of Observable.Empty.

Related errors


AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15). Data as JSON: /api/errors/c3bec7e49a50d107. Report an issue: GitHub.

Appendix: source

Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs:603

            if (source8 == null)
            {
                throw new ArgumentNullException(nameof(source8));
            }

            if (source9 == null)
            {
                throw new ArgumentNullException(nameof(source9));
            }

            if (source10 == null)
            {
                throw new ArgumentNullException(nameof(source10));
            }

            if (source11 == null)
            {
                throw new ArgumentNullException(nameof(source11));
            }

            if (resultSelector == null)
            {
                throw new ArgumentNullException(nameof(resultSelector));
            }

            return s_impl.CombineLatest(source1, source2, source3, source4, source5, source6, source7, source8, source9, source10, source11, resultSelector);
        }

        /// <summary>
        /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
        /// </summary>
        /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
        /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
        /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
        /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
        /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>

View on GitHub (pinned to 94b5d5ab91)