dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'progress')
Error message
Value cannot be null. (Parameter 'progress')
What it means
This ToObservable(IAsyncActionWithProgress, IProgress) overload requires a non-null progress reporter so progress notifications can be forwarded to observers. After validating 'source', it validates 'progress' and throws ArgumentNullException naming 'progress' when null. The library deliberately rejects null instead of silently dropping progress reports.
Solutions
- Pass a real IProgress<TProgress> implementation, e.g. new Progress<TProgress>(p => ...).
- Use the parameterless ToObservable() overload if you do not need forwarded progress; ToObservableProgress() reports progress to observers directly.
- Ensure any progress field/property is initialized before the conversion call.
Example fix
// before action.ToObservable(null).Subscribe(...); // after action.ToObservable(new Progress<MyProgress>(p => Console.WriteLine(p))).Subscribe(...);
Defensive patterns
Strategy: validation
Validate before calling
if (progress is null) throw new ArgumentNullException(nameof(progress));
Type guard
bool HasProgress<TProgress>(IProgress<TProgress>? p) => p is not null;
Try / catch
try { action.ToObservable(progress).Subscribe(...); }
catch (ArgumentNullException ex) when (ex.ParamName == "progress") { action.ToObservable().Subscribe(...); } Prevention
- Use new Progress<T>(callback) for the progress parameter.
- Call the overload without IProgress if you do not need external progress.
- Never pass null literals for IProgress parameters in these extensions.
When it happens
Trigger: Passing null (or an uninitialized IProgress<TProgress>) as the second argument to ToObservable on an IAsyncActionWithProgress<TProgress>.
Common situations: Developers copying the parameterless overload's call shape and passing null for progress, or a Progress<T> field not yet initialized when the extension is invoked.
Related errors
- source
- Value cannot be null. (Parameter 'source')
- Value cannot be null. (Parameter 'scheduler')
- Value cannot be null. (Parameter 'observer')
- comparer
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/c45e1cbd6de93719.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive.WindowsRuntime/AsyncInfoObservableExtensions.cs:84
/// <summary>
/// Converts a Windows Runtime asynchronous action to an observable sequence, reporting its progress through the supplied progress object.
/// Each observer subscribed to the resulting observable sequence will be notified about the action's successful or exceptional completion.
/// </summary>
/// <typeparam name="TProgress">The type of the reported progress objects.</typeparam>
/// <param name="source">Asynchronous action to convert.</param>
/// <param name="progress">Progress object to receive progress notifications on.</param>
/// <returns>An observable sequence that produces a unit value when the asynchronous action completes, or propagates the exception produced by the asynchronous action.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="progress"/> is null.</exception>
public static IObservable<Unit> ToObservable<TProgress>(this IAsyncActionWithProgress<TProgress> source, IProgress<TProgress> progress)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
if (progress == null)
{
throw new ArgumentNullException(nameof(progress));
}
return source.ToObservable_(progress);
}
/// <summary>
/// Converts a Windows Runtime asynchronous action to an observable sequence reporting its progress.
/// Each observer subscribed to the resulting observable sequence will be notified about the action's successful or exceptional completion.
/// </summary>
/// <typeparam name="TProgress">The type of the reported progress objects.</typeparam>
/// <param name="source">Asynchronous action to convert.</param>
/// <returns>An observable sequence that produces progress values from the asynchronous action and notifies observers about the action's completion.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public static IObservable<TProgress> ToObservableProgress<TProgress>(this IAsyncActionWithProgress<TProgress> source)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));View on GitHub (pinned to 94b5d5ab91)