dotnet/reactive · error · ArgumentNullException
ArgumentNullException(nameof(resourceFactory))
Error message
ArgumentNullException(nameof(resourceFactory))
What it means
Using validates resourceFactory, which must create the disposable resource governing the subscription lifetime; null is rejected because the resource could never be constructed or disposed. Fix: pass a non-null Func<TResource>.
Solutions
- Pass a non-null Func<TResource> that constructs the resource.
- Refactor to construct the resource explicitly if factory indirection is unnecessary.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/Using.cs:16 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/4c10e147b0d2af20.
Report an issue: GitHub.
Appendix: source
Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/Using.cs:16
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.
using System.Reactive.Disposables;
using System.Threading.Tasks;
namespace System.Reactive.Linq
{
public partial class AsyncObservable
{
public static IAsyncObservable<TResult> Using<TResult, TResource>(Func<TResource> resourceFactory, Func<TResource, IAsyncObservable<TResult>> observableFactory)
where TResource : IDisposable
{
if (resourceFactory == null)
throw new ArgumentNullException(nameof(resourceFactory));
if (observableFactory == null)
throw new ArgumentNullException(nameof(observableFactory));
return Create<TResult>(async observer =>
{
TResource resource;
try
{
resource = resourceFactory();
}
catch (Exception ex)
{
await observer.OnErrorAsync(ex).ConfigureAwait(false);
return AsyncDisposable.Nop;
}
IAsyncObservable<TResult> observable;
tryView on GitHub (pinned to 94b5d5ab91)