dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'ninth')
Error message
Value cannot be null. (Parameter 'ninth')
What it means
System.Reactive's public CombineLatest overload taking nine observable sequences validates every argument before delegating to the internal implementation. When the ninth observable source is null it throws ArgumentNullException with Parameter 'ninth'. This fail-fast guard exists so a bad composition fails immediately at the call site rather than later, deep inside subscription plumbing.
Solutions
- Ensure the ninth argument is a non-null IObservable<T>; if it may be absent, substitute Observable.Empty<T>() or a default source
- Inspect the expression producing the ninth sequence and fix whatever returns null (missing assignment, failed lookup)
- Wrap the composition call in a null check or ArgumentNullException-guard of your own to fail with a clearer message
- If sources come from a collection, use the IEnumerable-based CombineLatest overload after filtering out nulls
Example fix
// before IObservable<int> ninth = sources.Length > 8 ? sources[8] : null; // NRE/ArgumentNullException var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, ninth); // after IObservable<int> ninth = sources.Length > 8 ? sources[8] : Observable.Empty<int>(); var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, ninth);
Defensive patterns
Strategy: validation
Validate before calling
if (ninth == null) throw new ArgumentNullException(nameof(ninth)); // or: ninth ??= Observable.Empty<TNinth>();
Type guard
static bool IsNonNullSource<T>(IObservable<T> s) => s is not null;
Try / catch
try { return Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, ninth); }
catch (ArgumentNullException ex) when (ex.ParamName == "ninth") { /* log and use a default composition */ } Prevention
- Substitute Observable.Empty<T>() instead of null for absent sources
- Null-check all source sequences at your API boundary before composing
- Avoid null placeholders in long argument lists; build sequences via a collection and validate elements
When it happens
Trigger: Calling Observable.CombineLatest with nine IObservable<T> arguments (or via query syntax chains that map to it) where the ninth argument evaluates to null, e.g. a variable that was never assigned, a method returning null, or a dictionary/array lookup that missed.
Common situations: Building a sequence array/list at runtime and passing an element that ended up null; refactoring from fewer to more sources and leaving a placeholder null; a factory method returning null instead of Observable.Empty on some code path.
Related errors
- Value cannot be null. (Parameter 'source10')
- Value cannot be null. (Parameter 'source14')
- ArgumentNullException
- ArgumentNullException: resultSelector
- ArgumentNullException: source
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/ecb763c259e2251a.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs:1459
{
if (first == null)
throw new ArgumentNullException(nameof(first));
if (second == null)
throw new ArgumentNullException(nameof(second));
if (third == null)
throw new ArgumentNullException(nameof(third));
if (fourth == null)
throw new ArgumentNullException(nameof(fourth));
if (fifth == null)
throw new ArgumentNullException(nameof(fifth));
if (sixth == null)
throw new ArgumentNullException(nameof(sixth));
if (seventh == null)
throw new ArgumentNullException(nameof(seventh));
if (eighth == null)
throw new ArgumentNullException(nameof(eighth));
if (ninth == null)
throw new ArgumentNullException(nameof(ninth));
return s_impl.CombineLatest(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth);
}
/// <summary>
/// Merges the specified observable sequences into one observable sequence of tuple values whenever any of the observable sequences produces an element.
/// </summary>
/// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>
/// <typeparam name="TSecond">The type of the elements in the second source sequence.</typeparam>
/// <typeparam name="TThird">The type of the elements in the third source sequence.</typeparam>
/// <typeparam name="TFourth">The type of the elements in the fourth source sequence.</typeparam>
/// <typeparam name="TFifth">The type of the elements in the fifth source sequence.</typeparam>
/// <typeparam name="TSixth">The type of the elements in the sixth source sequence.</typeparam>
/// <typeparam name="TSeventh">The type of the elements in the seventh source sequence.</typeparam>
/// <typeparam name="TEighth">The type of the elements in the eighth source sequence.</typeparam>
/// <typeparam name="TNinth">The type of the elements in the ninth source sequence.</typeparam>
/// <typeparam name="TTenth">The type of the elements in the tenth source sequence.</typeparam>
/// <param name="first">First observable source.</param>View on GitHub (pinned to 94b5d5ab91)