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

  1. Pass the .Resource of the AzureSignalRResource created by AddAzureSignalR into the wrapper.
  2. Use builder.AddAzureSignalR(...).RunAsEmulator() instead of constructing the emulator resource manually.
  3. 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

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


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)