microsoft/aspire · error
DashboardClient is disabled. Check the IsEnabled property…
Error message
DashboardClient is disabled. Check the IsEnabled property before calling this.
What it means
EnsureInitialized enforces a state machine on DashboardClient. If the client was created with the feature disabled (StateDisabled), any call that requires initialization throws InvalidOperationException telling the caller to check the IsEnabled property first.
Solutions
- Check client.IsEnabled before calling any DashboardClient methods and skip/disable the dependent feature when false.
- Enable the resource service client in configuration so the client initializes (provide valid auth endpoints/certs).
- If hosting the dashboard yourself, register/configure the DashboardClient (AddDashboardClient) instead of relying on a disabled instance.
- Subscribe to the client's state/initialization events rather than assuming it is usable.
Example fix
// before
await dashboardClient.StartAsync(cancellationToken);
await dashboardClient.GetResourcesAsync(cancellationToken);
// after
if (dashboardClient.IsEnabled)
{
await dashboardClient.StartAsync(cancellationToken);
await dashboardClient.GetResourcesAsync(cancellationToken);
} Defensive patterns
Strategy: type-guard
Type guard
if (!dashboardClient.IsEnabled)
{
logger.LogWarning("DashboardClient disabled; skipping resource watch.");
return;
} Try / catch
try { await dashboardClient.StartAsync(ct); }
catch (InvalidOperationException ex) when (ex.Message.Contains("is disabled"))
{
logger.LogWarning("DashboardClient is disabled; feature unavailable.");
} Prevention
- Always gate DashboardClient usage behind an IsEnabled check.
- Enable the resource service client in configuration if the feature is needed.
- Cover both enabled and disabled config paths in feature tests.
When it happens
Trigger: Calling StartAsync/GetResources/etc. on a DashboardClient constructed while the dashboard resource-service client was disabled — i.e. IsEnabled was false but client methods were invoked anyway.
Common situations: Consumer code (e.g. structured logs/metrics/traces pages) not checking DashboardClient.IsEnabled when the resource service client is intentionally disabled by configuration; using the client in unit tests with default options where the client is disabled.
Related errors
- State has not been loaded.
- A BlobServiceClient could not be configured. Ensure valid…
- A BlobServiceClient could not be configured. Ensure valid…
- A ChatCompletionsClient could not be configured. Ensure…
- A Container could not be configured. Ensure valid…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/4434da94f1ea2ec8.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Dashboard/ServiceClient/DashboardClient.cs:328
if (_initialDataReceivedTcs.Task.IsCompleted)
{
_initialDataReceivedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
}
}
}
// Invoke the event outside the lock to avoid potential deadlocks
// if a subscriber tries to access DashboardClient state.
ConnectionStateChanged?.Invoke(state);
}
private void EnsureInitialized()
{
var priorState = Interlocked.CompareExchange(ref _state, value: StateInitialized, comparand: StateNone);
if (priorState is StateDisabled)
{
throw new InvalidOperationException($"{nameof(DashboardClient)} is disabled. Check the {nameof(IsEnabled)} property before calling this.");
}
if (priorState is not StateNone)
{
ObjectDisposedException.ThrowIf(priorState is StateDisposed, this);
return;
}
SetConnectionState(DashboardConnectionState.Connecting);
// The connection watches resources for the lifetime of the dashboard. Don't let the request or
// component that first accesses the client become the parent of that long-running operation.
using (ExecutionContext.SuppressFlow())
{
_connection = Task.Run(() => ConnectAndWatchAsync(_clientCancellationToken), _clientCancellationToken);
}
}
async Task ConnectAndWatchAsync(CancellationToken cancellationToken)View on GitHub (pinned to 25830f84bd)