microsoft/aspire · error · ArgumentNullException
Value cannot be null. (Parameter 'processRunner')
Error message
Value cannot be null. (Parameter 'processRunner')
What it means
The ContainerRuntimeBase protected constructor guards its IProcessRunner dependency with ArgumentNullException. Without a process runner the runtime cannot execute docker/podman commands, so construction is refused.
Solutions
- Register IProcessRunner in the DI container and resolve it when creating the runtime.
- In tests, supply a real ProcessRunner or a hand-written stub implementing IProcessRunner.
- Forward the dependency from the subclass constructor instead of passing null.
Example fix
// before new DockerRuntime(logger, null!); // after services.AddSingleton<IProcessRunner, ProcessRunner>(); new DockerRuntime(logger, services.GetRequiredService<IProcessRunner>());
Defensive patterns
Strategy: type-guard
Validate before calling
if (processRunner is null) throw new InvalidOperationException("ContainerRuntimeBase requires a non-null IProcessRunner"); Type guard
static bool CanCreateRuntime(ILogger<DockerRuntime>? logger, IProcessRunner? runner) => logger is not null && runner is not null;
Try / catch
try { runtime = new DockerRuntime(logger, processRunner); }
catch (ArgumentNullException ex) when (ex.ParamName is "logger" or "processRunner")
{
processRunner ??= new ProcessRunner(TimeProvider.System, logger!, new DefaultProcessExecutionContextLogger(logger!));
runtime = new DockerRuntime(logger!, processRunner);
} Prevention
- Register IProcessRunner as a singleton in the AppHost DI container.
- In tests, provide a stub IProcessRunner instead of null.
- Constructor-forward dependencies in custom runtime subclasses rather than defaulting to null.
When it happens
Trigger: Constructing a concrete ContainerRuntimeBase subclass passing null for the IProcessRunner parameter.
Common situations: IProcessRunner not registered in DI; manual construction in tests passing null; custom subclass hardcoding null instead of forwarding the dependency.
Related errors
- Value cannot be null. (Parameter 'logger')
- A QueueServiceClient could not be configured. Ensure valid…
- An EventProcessorClient could not be configured. Ensure a…
- Application did not register an implementation of
- ArgumentNullException for parameter 'services' (services is…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/2a696b3b26c9e7eb.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/Publishing/ContainerRuntimeBase.cs:29
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Dcp.Process;
using Microsoft.Extensions.Logging;
namespace Aspire.Hosting.Publishing;
/// <summary>
/// Base class for container runtime implementations that provides common process execution,
/// logging, and error handling patterns.
/// </summary>
internal abstract class ContainerRuntimeBase<TLogger> : IContainerRuntime where TLogger : class
{
private readonly ILogger<TLogger> _logger;
private readonly IProcessRunner _processRunner;
protected ContainerRuntimeBase(ILogger<TLogger> logger, IProcessRunner processRunner)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_processRunner = processRunner ?? throw new ArgumentNullException(nameof(processRunner));
}
/// <summary>
/// Gets the logger instance for use in derived classes.
/// </summary>
protected ILogger<TLogger> Logger => _logger;
/// <summary>
/// Gets the process runner used for container runtime commands.
/// </summary>
protected IProcessRunner ProcessRunner => _processRunner;
/// <summary>
/// Gets the name of the container runtime executable (e.g., "docker", "podman").
/// </summary>
protected abstract string RuntimeExecutable { get; }
public abstract string Name { get; }View on GitHub (pinned to 25830f84bd)