Skip to content

TypeScript AppHost code generation can fail with empty TypeLoadException when CLI and restored SDK DLL builds differ #16709

@davidfowl

Description

@davidfowl

Description

A TypeScript/Node.js AppHost intermittently failed during Aspire TypeScript SDK code generation before any app resources started. The CLI surfaced a generic System.TypeLoadException with no type name, missing member, or assembly details, followed by a 60 second AppHost startup timeout.

The same failure also occurred when running aspire restore. A later aspire start succeeded without changing AppHost source or aspire.config.json, so this may be intermittent or cache/version-state dependent.

The strongest clue is that the installed CLI build was older than the restored SDK/codegen DLLs used for the TypeScript AppHost:

  • CLI: 13.3.0-preview.1.26218.1
  • Restored AppHost/codegen packages: 13.3.0-preview.1.26227.17

Environment

  • OS: Windows, win-arm64
  • AppHost type: TypeScript / Node.js
  • Aspire channel: daily

Installed CLI

aspire --version
13.3.0-preview.1.26218.1+80eca9ec09dc40596c1510d805570b1f62c5cc72

~\.aspire\bin\aspire.exe:

FileVersion:    13.300.26.21801
ProductVersion: 13.3.0-preview.1.26218.1+80eca9ec09dc40596c1510d805570b1f62c5cc72

Project aspire.config.json

{
  "appHost": {
    "path": "apphost.ts",
    "language": "typescript/nodejs"
  },
  "sdk": {
    "version": "13.3.0-preview.1.26227.17"
  },
  "channel": "daily",
  "packages": {
    "Aspire.Hosting.JavaScript": "13.3.0-preview.1.26227.17"
  }
}

~/.aspire state

At the time of failure, ~\.aspire contained the installed Aspire CLI, package restore cache, runtime socket state, and logs.

Top-level notable entries:

~\.aspire\bin
~\.aspire\cache
~\.aspire\cli
~\.aspire\dcp
~\.aspire\dcp.old.<redacted>
~\.aspire\hosts
~\.aspire\logs
~\.aspire\managed
~\.aspire\packages
~\.aspire\.aspire-bundle-version
~\.aspire\aspire.config.json

Package restore cache:

~\.aspire\packages\restore\831D2C3871E3E03B  LastWriteTime: 2026-05-03 08:59  Size: ~52.52 MB
~\.aspire\packages\restore\832295CC3E4149C2  LastWriteTime: 2026-04-29 18:30  Size: ~14.82 MB

The most recent restore directory contained these Aspire packages:

Aspire.Hosting.CodeGeneration.TypeScript/13.3.0-preview.1.26227.17
Aspire.Hosting.JavaScript/13.3.0-preview.1.26227.17
Aspire.Hosting/13.3.0-preview.1.26227.17
Aspire.TypeSystem/13.3.0-preview.1.26227.17

There were also many stale-looking zero-byte runtime socket files under:

~\.aspire\cli\runtime\sockets\cli.sock.<id>

The current run eventually succeeded with a new socket, but the earlier failed runs left logs showing the TypeLoadException.

Restored DLL versions

From the most recent restore directory:

~\.aspire\packages\restore\831D2C3871E3E03B\libs

DLL AssemblyVersion FileVersion ProductVersion
Aspire.Hosting.CodeGeneration.TypeScript.dll 13.3.0.0 13.300.26.22717 13.3.0-preview.1.26227.17+4178550db8344fd67282962d544c53adb8994d7b
Aspire.Hosting.dll 13.3.0.0 13.300.26.22717 13.3.0-preview.1.26227.17+4178550db8344fd67282962d544c53adb8994d7b
Aspire.Hosting.JavaScript.dll 13.3.0.0 13.300.26.22717 13.3.0-preview.1.26227.17+4178550db8344fd67282962d544c53adb8994d7b
Aspire.TypeSystem.dll 13.3.0.0 13.300.26.22717 13.3.0-preview.1.26227.17+4178550db8344fd67282962d544c53adb8994d7b

So the process was using CLI build 26218 with restored TypeScript AppHost/codegen DLLs from build 26227.

Steps observed

  1. Run aspire start for an existing TypeScript AppHost.
  2. CLI stops the previous AppHost instance.
  3. New AppHost startup fails while generating TypeScript code via RPC.
  4. Run aspire restore.
  5. Restore fails with the same System.TypeLoadException.
  6. A later aspire start succeeds without AppHost source/config changes.

Expected behavior

If the failure is caused by CLI/SDK/package version skew, generated TypeScript SDK incompatibility, or stale/corrupt cache state, Aspire should fail with an actionable diagnostic that includes the missing type/member/assembly identity and recommended remediation.

aspire start and aspire restore should not reduce this to an empty System.TypeLoadException followed by a generic timeout.

Actual behavior

aspire start failed with an empty System.TypeLoadException from TypeScript code generation, then timed out waiting for the AppHost server.

aspire restore failed with the same System.TypeLoadException.

Sanitized logs

aspire start

[2026-05-03 15:59:19.054] [INFO] [Program] Version: 13.3.0-preview.1.26218.1+80eca9ec09dc40596c1510d805570b1f62c5cc72
[2026-05-03 15:59:19.055] [INFO] [Program] Build ID: 13.300.26.21801
[2026-05-03 15:59:19.055] [INFO] [Program] Working directory: <REPO>\local\aspire
[2026-05-03 15:59:19.055] [INFO] [Program] Log file: <USERPROFILE>\.aspire\logs\cli_20260503T155919015_detach-child_<redacted>.log
[2026-05-03 15:59:24.227] [DBUG] [GuestAppHostProject] Generating TypeScript code via RPC for 3 packages
[2026-05-03 15:59:24.274] [FAIL] [GuestAppHostProject] Failed to run TypeScript (Node.js) AppHost
StreamJsonRpc.RemoteInvocationException
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__159`1.MoveNext() + 0x4e8
--- End of stack trace from previous location ---
   at Aspire.Cli.Projects.GuestAppHostProject.<GenerateCodeViaRpcAsync>d__53.MoveNext() + 0x84
--- End of stack trace from previous location ---
   at Aspire.Cli.Projects.GuestAppHostProject.<RunAsync>d__39.MoveNext() + 0xb98
--- End of stack trace from previous location ---
   at Aspire.Cli.Projects.GuestAppHostProject.<RunAsync>d__39.MoveNext() + 0x1424
RPC server exception:
System.TypeLoadException:
      at Aspire.Hosting.CodeGeneration.TypeScript.AtsTypeScriptCodeGenerator.GenerateAspireSdk(AtsContext context) in /_/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs:line 564
      at Aspire.Hosting.CodeGeneration.TypeScript.AtsTypeScriptCodeGenerator.GenerateAspireSdk(AtsContext context) in /_/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs:line 564
      at Aspire.Hosting.CodeGeneration.TypeScript.AtsTypeScriptCodeGenerator.GenerateDistributedApplication(AtsContext context) in /_/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs:line 533
      at Aspire.Hosting.RemoteHost.CodeGeneration.CodeGenerationService.GenerateCode(String language, String assemblyName) in D:\a\_work\1\s\src\Aspire.Hosting.RemoteHost\CodeGeneration\CodeGenerationService.cs:line 185
      at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
      at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

[2026-05-03 15:59:24.275] [INFO] [Stdout] ❌ Failed to run TypeScript (Node.js) AppHost:
[2026-05-03 16:00:21.586] [INFO] [Stdout] ❌ An unexpected error occurred: Timed out waiting for AppHost server to start after 60 seconds. Check the debug logs for more details.
[2026-05-03 16:00:21.588] [DBUG] [CliUpdateNotifier] Current version: 13.3.0-preview.1.26218.1
Newest stable version: 13.2.4
Newest prerelease version: (null)
[2026-05-03 16:00:21.588] [INFO] [Program] Exit code: 2

aspire restore

   at Aspire.Cli.Commands.RestoreCommand.<ExecuteAsync>d__11.MoveNext() + 0x180
RPC server exception:
System.TypeLoadException:
      at Aspire.Hosting.CodeGeneration.TypeScript.AtsTypeScriptCodeGenerator.GenerateAspireSdk(AtsContext context) in /_/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs:line 564
      at Aspire.Hosting.CodeGeneration.TypeScript.AtsTypeScriptCodeGenerator.GenerateAspireSdk(AtsContext context) in /_/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs:line 564
      at Aspire.Hosting.CodeGeneration.TypeScript.AtsTypeScriptCodeGenerator.GenerateDistributedApplication(AtsContext context) in /_/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs:line 533
      at Aspire.Hosting.RemoteHost.CodeGeneration.CodeGenerationService.GenerateCode(String language, String assemblyName) in /_/src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs:line 185
      at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
      at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

Notes

The logs do not include the missing type name, missing method name, or assembly identity. That makes it hard to determine whether this is caused by version skew between the installed CLI and configured daily SDK/packages, stale generated .modules state, stale ~\.aspire restore/runtime cache, or another codegen issue.

A subsequent aspire start succeeded and the AppHost resources became healthy, so this may require investigating transient cache or version resolution behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions