microsoft/aspire · error · ArgumentException

No code generator found for language

Error message

No code generator found for language: {language}. Available languages: {string.Join(", ", available)}. (When none discovered: No code generator found for language: {language}. No code generators were discovered in any loaded assembly. This usually indicates a binary mismatch between the bundled apphost server and the integration assemblies on disk; check the apphost server log for 'LoaderExceptions' Warnings.)

What it means

CodeGenerationService.GenerateCode resolves a code generator for the requested language through an ICodeGeneratorResolver over all loaded assemblies. If none is registered (generator == null) it throws ArgumentException with a message listing the languages that WERE discovered, or — when none were discovered at all — a hint that this usually indicates a binary mismatch between the bundled apphost server and the integration assemblies on disk (check the apphost server log for 'LoaderExceptions' Warnings).

Solutions

  1. Use one of the languages listed in the 'Available languages' portion of the message.
  2. Check the apphost server log for 'LoaderExceptions' Warnings and fix assembly load failures.
  3. Align the bundled apphost server version with the Aspire integration assemblies on disk (update SDK/packages together, clean bin/obj).
  4. Ensure your project references a package that ships the generator for the target language.

Example fix

// before: unsupported language id
await client.CallCapabilityAsync("generateCode", new { language = "ts" });
// after
await client.CallCapabilityAsync("generateCode", new { language = "typescript" });
Defensive patterns

Strategy: validation

Validate before calling

// discover supported languages before calling generateCode
var languages = client.GetAvailableLanguages(); // from resolver/discovery API
if (!languages.Contains(language))
    throw new ArgumentException($"Language '{language}' unavailable. Supported: {string.Join(", ", languages)}");

Type guard

static bool IsSupportedLanguage(string language, IEnumerable<string> available) =>
    available.Contains(language, StringComparer.OrdinalIgnoreCase);

Try / catch

try { await service.GenerateCode(language); }
catch (ArgumentException ex) when (ex.Message.Contains("No code generator found"))
{ log.LogError(ex, "Unsupported language or generator assemblies failed to load"); throw; }

Prevention

When it happens

Trigger: Invoking the generateCode ATS capability with a language string (e.g. 'typescript', 'python') for which no discovered code generator exists, or when the scan found no ICodeGenerator implementations in any loaded assembly because integration assemblies failed to load.

Common situations: Typo/unsupported language name; version-skew where the apphost server bundle predates the generator assemblies on disk; integration DLLs blocked or failing to load (loader exceptions, missing dependencies), so no generators register.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/94f1f9ddc5d3fb0e. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs:248

    /// Generates SDK code for the specified language.
    /// </summary>
    /// <param name="language">The target language (e.g., "TypeScript", "Python").</param>
    /// <param name="assemblyName">The exporting assembly to scope the generated SDK to, or null to use the full ATS context.</param>
    /// <returns>A dictionary of file paths to file contents.</returns>
    [JsonRpcMethod(GenerateCodeMethodName)]
    public Dictionary<string, string> GenerateCode(string language, string? assemblyName = null)
    {
        using var rpcActivity = _profilingTelemetry.StartJsonRpcServerCall(GenerateCodeMethodName);
        using var activity = _profilingTelemetry.StartCodeGenerationGenerate(language);
        try
        {
            _authenticationState.ThrowIfNotAuthenticated();
            _logger.LogDebug(">> generateCode({Language})", language);
            var sw = System.Diagnostics.Stopwatch.StartNew();
            var generator = _resolver.GetCodeGenerator(language);
            if (generator == null)
            {
                throw new ArgumentException(BuildNoCodeGeneratorMessage(language));
            }

            var context = _atsContextFactory.GetContext();
            if (!string.IsNullOrWhiteSpace(assemblyName))
            {
                // Scoped source generation must not use the API-export filter: its synthetic
                // supporting capabilities are projection-only metadata and would otherwise become
                // executable members in the generated SDK.
                context = AtsContextFilter.FilterByExportingAssembliesWithReferences(context, [assemblyName]);
            }

            var files = generator.GenerateDistributedApplication(context);
            activity.SetFileCount(files.Count);

            _logger.LogDebug("<< generateCode({Language}) completed in {ElapsedMs}ms, generated {FileCount} files", language, sw.ElapsedMilliseconds, files.Count);
            return files;
        }
        catch (Exception ex)

View on GitHub (pinned to 25830f84bd)