microsoft/aspire · error · ArgumentNullException
Value cannot be null. (Parameter 'logger')
Error message
Value cannot be null. (Parameter 'logger')
What it means
This obsolete ResourceNotificationService constructor requires a non-null ILogger<ResourceNotificationService>. Passing null fails fast via ArgumentNullException. The constructor exists only for backward compatibility and will be removed.
Solutions
- Use the 4-parameter constructor (ILogger, IHostApplicationLifetime, IServiceProvider, ResourceLoggerService)
- Register ILogger<T> in the DI container or use NullLogger<ResourceNotificationService>.Instance in tests
- Remove direct construction and resolve the service from DI
Example fix
// before
new ResourceNotificationService(null, lifetime);
// after
new ResourceNotificationService(NullLogger<ResourceNotificationService>.Instance, lifetime,
services, new ResourceLoggerService()); Defensive patterns
Strategy: validation
Validate before calling
if (logger is null) logger = NullLogger<ResourceNotificationService>.Instance;
Try / catch
try { var svc = new ResourceNotificationService(logger, lifetime); }
catch (ArgumentNullException) { /* supply a logger or migrate to the DI constructor */ } Prevention
- Migrate off the obsolete 2-parameter constructor
- Use NullLogger<T>.Instance in tests instead of null
When it happens
Trigger: Calling new ResourceNotificationService(null, hostApplicationLifetime) or passing a null logger from legacy host-building code.
Common situations: Migrating old code that previously constructed the service manually; DI containers supplying null due to missing ILogger registrations.
Related errors
- adminPassword
- Array params contains null item
- Value cannot be null. (Parameter 'iconName')
- Value cannot be null. (Parameter 'innerResource')
- Value cannot be null. (Parameter 'resource')
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/174c065d49ac3229.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs:55
internal WaitBehavior DefaultWaitBehavior { get; set; }
/// <summary>
/// Creates a new instance of <see cref="ResourceNotificationService"/>.
/// </summary>
/// <remarks>
/// Obsolete. Use the constructor that accepts an <see cref="ILogger{ResourceNotificationService}"/>, <see cref="IHostApplicationLifetime"/> and <see cref="IServiceProvider"/>.<br/>
/// This constructor will be removed in the next major version of Aspire.
/// </remarks>
/// <param name="logger">The logger.</param>
/// <param name="hostApplicationLifetime">The host application lifetime.</param>
[Obsolete($"""
{nameof(ResourceNotificationService)} now requires an {nameof(IServiceProvider)} and {nameof(ResourceLoggerService)}.
Use the constructor that accepts an {nameof(ILogger)}<{nameof(ResourceNotificationService)}>, {nameof(IHostApplicationLifetime)}, {nameof(IServiceProvider)} and {nameof(ResourceLoggerService)}.
This constructor will be removed in the next major version of Aspire.
""")]
public ResourceNotificationService(ILogger<ResourceNotificationService> logger, IHostApplicationLifetime hostApplicationLifetime)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_serviceProvider = new NullServiceProvider();
_resourceLoggerService = new ResourceLoggerService();
DefaultWaitBehavior = WaitBehavior.StopOnResourceUnavailable;
}
/// <summary>
/// Creates a new instance of <see cref="ResourceNotificationService"/>.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="hostApplicationLifetime">The host application lifetime.</param>
/// <param name="resourceLoggerService">The resource logger service.</param>
/// <param name="serviceProvider">The service provider.</param>
public ResourceNotificationService(
ILogger<ResourceNotificationService> logger,
IHostApplicationLifetime hostApplicationLifetime,
IServiceProvider serviceProvider,
ResourceLoggerService resourceLoggerService)
{View on GitHub (pinned to 25830f84bd)