dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'sixteenth')

Error message

Value cannot be null. (Parameter 'sixteenth')

What it means

The public Observable.CombineLatest 16-source overload throws ArgumentNullException when the sixteenth (last) source sequence is null. This is the final null check in the validation chain before delegating to the internal implementation. Pass a real IObservable for the sixteenth argument.

Solutions

  1. Ensure a valid non-null IObservable is supplied as the sixteenth argument.
  2. Replace null with Observable.Empty<T>() or Observable.Never<T>() when a source is intentionally absent.
  3. Pre-validate all 16 observables for null before the call.

Example fix

// before
Observable.CombineLatest(s1, ..., s15, lastSource /* null */, selector);
// after
var sixteenth = lastSource ?? Observable.Empty<LastType>();
Observable.CombineLatest(s1, ..., s15, sixteenth, selector);
Defensive patterns

Strategy: validation

Validate before calling

if (sixteenth == null) throw new InvalidOperationException("sixteenth source must be provided");

Type guard

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

Try / catch

try { return Observable.CombineLatest(s1, /* ... */, s15, s16, selector); }
catch (ArgumentNullException ex) when (ex.ParamName == "sixteenth") { /* fix wiring or fall back */ }

Prevention

When it happens

Trigger: Calling Observable.CombineLatest(first..sixteenth, resultSelector) with null passed as the sixteenth observable argument.

Common situations: A conditionally-created last observable left null; copy-paste of an overload call with too few sources; a helper returning null instead of an empty observable.

Related errors


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

Appendix: source

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

                throw new ArgumentNullException(nameof(seventh));
            if (eighth == null)
                throw new ArgumentNullException(nameof(eighth));
            if (ninth == null)
                throw new ArgumentNullException(nameof(ninth));
            if (tenth == null)
                throw new ArgumentNullException(nameof(tenth));
            if (eleventh == null)
                throw new ArgumentNullException(nameof(eleventh));
            if (twelfth == null)
                throw new ArgumentNullException(nameof(twelfth));
            if (thirteenth == null)
                throw new ArgumentNullException(nameof(thirteenth));
            if (fourteenth == null)
                throw new ArgumentNullException(nameof(fourteenth));
            if (fifteenth == null)
                throw new ArgumentNullException(nameof(fifteenth));
            if (sixteenth == null)
                throw new ArgumentNullException(nameof(sixteenth));

            return s_impl.CombineLatest(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth);
        }

    }
}

View on GitHub (pinned to 94b5d5ab91)