dotnet/reactive · error · ArgumentNullException
throw new ArgumentNullException(nameof(provider))
Error message
throw new ArgumentNullException(nameof(provider))
What it means
QbservableEx.Create(provider, iteratorMethod) requires an IQbservableProvider to build the remote query. A null provider is rejected immediately with ArgumentNullException named 'provider'. Rx throws eagerly so invalid queries fail at composition rather than at subscription time on the provider.
Solutions
- Pass a valid IQbservableProvider, e.g. from an existing query's .Provider or Qbservable.Provider
- Resolve the provider from your DI/ServiceProvider and verify registration is non-null
- Guard the call site with a null check on the provider before invoking Create
Example fix
// before
Qbservable.Create(provider, iteratorMethod);
// after
if (provider == null) throw new InvalidOperationException("No IQbservableProvider configured");
Qbservable.Create(provider, iteratorMethod); Defensive patterns
Strategy: validation
Validate before calling
if (provider == null)
throw new InvalidOperationException("IQbservableProvider is not configured"); Type guard
bool HasProvider(IQbservableProvider p) => p is not null;
Try / catch
try
{
var query = Qbservable.Create(provider, iteratorMethod);
}
catch (ArgumentNullException ex) when (ex.ParamName == "provider")
{
logger.LogError(ex, "Provider was null when composing Create query");
} Prevention
- Register IQbservableProvider in DI and fail fast at startup if unresolved
- Obtain providers from an existing query's .Provider rather than nullable variables
- Never propagate ?. chains that silently yield null providers
When it happens
Trigger: Calling Qbservable.Create(null, iteratorMethod) — typically when the provider came from a null source.Provider, an uninitialized service locator, or a conditional expression like qbservable?.Provider.
Common situations: Chaining .Provider off a query built conditionally; DI container returning null for IQbservableProvider; using the extension before the queryable source was initialized in test scaffolding.
Related errors
- throw new ArgumentNullException(nameof(iteratorMethod))
- throw new ArgumentNullException(nameof(sixteenth))
- throw new ArgumentNullException(nameof(source))
- eleventh
- fifteenth
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/ab7478dd0eab5035.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs:965
GetSourceExpression(sixteenth)
)
);
}
#if !STABLE
/// <summary>
/// Subscribes to each observable sequence returned by the iteratorMethod in sequence and produces a Unit value on the resulting sequence for each step of the iteration.
/// </summary>
/// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
/// <param name="iteratorMethod">Iterator method that drives the resulting observable sequence.</param>
/// <returns>An observable sequence obtained by running the iterator and returning Unit values for each iteration step.</returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="iteratorMethod" /> is null.</exception>
[Experimental]
public static IQbservable<Unit> Create(this IQbservableProvider provider, Expression<Func<IEnumerable<IObservable<object>>>> iteratorMethod)
{
if (provider == null)
throw new ArgumentNullException(nameof(provider));
if (iteratorMethod == null)
throw new ArgumentNullException(nameof(iteratorMethod));
return provider.CreateQuery<Unit>(
Expression.Call(
null,
new Func<IQbservableProvider, Expression<Func<IEnumerable<IObservable<object>>>>, IQbservable<Unit>>(Create).Method,
Expression.Constant(provider, typeof(IQbservableProvider)),
iteratorMethod
)
);
}
#endif
#if !STABLE
/// <summary>
/// Subscribes to each observable sequence returned by the iteratorMethod in sequence and returns the observable sequence of values sent to the observer given to the iteratorMethod.
/// </summary>View on GitHub (pinned to 94b5d5ab91)