microsoft/aspire · error · ArgumentNullException
innerResource
Error message
innerResource
What it means
AzureSignalREmulatorResource throws ArgumentNullException when the inner AzureSignalRResource is null. The emulator wrapper stores all annotations on the inner resource, so a null inner resource would break every annotation operation.
Solutions
- Pass the .Resource of the AzureSignalRResource created by AddAzureSignalR into the wrapper.
- Use builder.AddAzureSignalR(...).RunAsEmulator() instead of constructing the emulator resource manually.
- Ensure the lookup that produced the inner resource cannot return null before constructing.
Example fix
// before
var emulator = new AzureSignalREmulatorResource(FindSignalR("signalr"));
// after
var signalr = builder.AddAzureSignalR("signalr");
var emulator = new AzureSignalREmulatorResource(signalr.Resource); Defensive patterns
Strategy: validation
Validate before calling
if (signalrResource is null) throw new InvalidOperationException("AddAzureSignalR must run before creating the emulator resource."); Type guard
if (signalrResource is not null) { var emulator = new AzureSignalREmulatorResource(signalrResource); } Prevention
- Use RunAsEmulator() on the SignalR builder instead of manual wrapping.
- Never feed nullable resource lookups into wrapper constructors.
- Keep resource creation and emulator configuration in one chain.
When it happens
Trigger: Constructing AzureSignalREmulatorResource directly with a null AzureSignalRResource argument, e.g. in RunAsEmulator call chains where the SignalR resource was not resolved.
Common situations: Custom code that looks up the AzureSignalRResource by name (returning null when not found) and passes it into the emulator wrapper; tests constructing the wrapper in isolation.
Related errors
- ArgumentNullException for parameter 'callback' (callback is…
- ArgumentNullException for parameter 'resource' (resource is…
- ArgumentNullException for parameter 'services' (services is…
- ArgumentNullException: hostBuilder
- BlobServiceClient is not initialized.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/f14281e82e5f8cdf.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.SignalR/AzureSignalREmulatorResource.cs:14
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Aspire.Hosting.ApplicationModel;
namespace Aspire.Hosting.Azure;
/// <summary>
/// Wraps an <see cref="AzureSignalRResource" /> in a type that exposes container extension methods.
/// </summary>
/// <param name="innerResource">The inner resource used to store annotations.</param>
public class AzureSignalREmulatorResource(AzureSignalRResource innerResource) : ContainerResource(innerResource.Name), IResource
{
private readonly AzureSignalRResource _innerResource = innerResource ?? throw new ArgumentNullException(nameof(innerResource));
/// <inheritdoc/>
public override ResourceAnnotationCollection Annotations => _innerResource.Annotations;
}
View on GitHub (pinned to 25830f84bd)