microsoft/aspire · error · InvalidOperationException
Unknown resource type
Error message
Unknown resource type {resource.GetType().Name} What it means
GetResourceType maps an application-model resource to its DCP kind via a switch over Container/Executable/ContainerExec; any other DCP resource type falls through to an InvalidOperationException. It is an internal completeness guard: the executor encountered a DCP object it does not know how to classify.
Solutions
- Update to matching versions of all Aspire.* packages so DCP object kinds align.
- If you wrote a custom resource/DCP object, extend the mapping to emit a supported kind (Container, Executable, or ContainerExec).
- Check third-party hosting integrations for a newer version supporting your resource type.
- Report the resource type name shown in the message to the integration/library maintainer if it comes from a package.
Example fix
// before: custom resource unmapped in DCP projection
var dcpObject = new MyCustomDcpType { ... };
// after: project to a supported DCP kind
var dcpObject = new Executable { ... }; // or Container / ContainerExec Defensive patterns
Strategy: type-guard
Type guard
static bool HasSupportedDcpKind(object dcpObject) =>
dcpObject is Container or Executable or ContainerExec; Try / catch
try
{
var kind = executor.ResourceType(resource);
}
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Unknown resource type"))
{
logger.LogError(ex, "Unsupported DCP object for {Resource}; check integration versions.", resource.Name);
} Prevention
- Keep all Aspire.* packages at identical versions.
- When authoring integrations, only emit Container/Executable/ContainerExec DCP objects.
- Re-run integration tests after adding new DCP object kinds to catch unhandled switches.
- Review custom IDcpObjectFactory implementations for completeness.
When it happens
Trigger: DcpExecutor creates DCP objects for a resource whose DCP type is not one of Container, Executable, or ContainerExec (via GetResourceType, backing the resourceType property).
Common situations: A custom resource or new DCP object kind introduced without updating DcpExecutor's switch; version skew between Aspire.Hosting assemblies; custom IDcpObjectFactory implementations emitting unsupported types.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Could not generate a unique name for service
- Unknown file system entry type
- A JSON Patch operation must contain string 'op' and 'path'…
- All resources should be of the same kind when calling…
- Application orchestrator dependency check returned an…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/2fb7ea2ca1025428.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/Dcp/DcpExecutor.cs:382
(applicationName[i] is >= 'A' and <= 'Z') ||
(applicationName[i] is >= '0' and <= '9') ||
(applicationName[i] is '_' or '-' or '.'))
{
normalizedName.Append(applicationName[i]);
}
}
return normalizedName.ToString();
}
internal static string GetResourceType<T>(T resource, IResource appModelResource) where T : CustomResource
{
return resource switch
{
Container => KnownResourceTypes.Container,
Executable => appModelResource.GetResourceType(),
ContainerExec => KnownResourceTypes.ContainerExec,
_ => throw new InvalidOperationException($"Unknown resource type {resource.GetType().Name}")
};
}
Task IDcpObjectFactory.UpdateWithEffectiveAddressInfo(IEnumerable<Service> services, CancellationToken cancellationToken, TimeSpan? timeout)
=> UpdateWithEffectiveAddressInfo(services, cancellationToken, timeout);
// Watches DCP object updates via a Kubernetes watch wrapped in the supplied retry pipeline,
// till all objects reach desired state or a timeout occurs.
// Returns names of objects that did not reach the desired state.
private async Task<HashSet<string>> WatchUntilDesiredStateAsync<TDcpResource>(
IEnumerable<TDcpResource> objects,
Func<TDcpResource, TDcpResource, bool> isInDesiredState,
ResiliencePipeline pipeline,
CancellationToken cancellationToken)
where TDcpResource : CustomResource, IKubernetesStaticMetadata
{
var objectsByName = new Dictionary<string, TDcpResource>(StringComparer.Ordinal);
var pending = new HashSet<string>(StringComparer.Ordinal);View on GitHub (pinned to 25830f84bd)