Skip to content

Exception.ToString is different with .NET 11 #128723

@richlander

Description

@richlander

Program.cs:

using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

Console.WriteLine(RuntimeInformation.FrameworkDescription);



await OuterAsync();

static async Task OuterAsync()
{
    await Task.CompletedTask;
    await MiddleAsync();
}

static async Task MiddleAsync()
{
    await Task.CompletedTask;
    await InnerAsync();
   throw new InvalidOperationException("boom");
}

static async Task InnerAsync()
{
    await Task.CompletedTask;
}

project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net11.0;net10.0</TargetFrameworks>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <Features Condition="'$(TargetFramework)' == 'net11.0'">runtime-async=on</Features>
  </PropertyGroup>
</Project>

.NET 10 (everything default):

$ dotnet run -f net10.0
.NET 10.0.8
Unhandled exception. System.InvalidOperationException: boom
   at Program.<<Main>$>g__MiddleAsync|0_1() in /Users/rich/git/build-talk-2026/runtime-async-demo/Program.cs:line 24
   at Program.<<Main>$>g__OuterAsync|0_0() in /Users/rich/git/build-talk-2026/runtime-async-demo/Program.cs:line 15
   at Program.<Main>$(String[] args) in /Users/rich/git/build-talk-2026/runtime-async-demo/Program.cs:line 10
   at Program.<Main>(String[] args)

.NET 11 (async v2 off):

dotnet run -f net11.0
.NET 11.0.0-preview.4.26230.115
Unhandled exception. System.InvalidOperationException: boom
   at Program.<<Main>$>g__MiddleAsync|0_1() in /Users/rich/git/build-talk-2026/runtime-async-demo/Program.cs:line 24
   at Program.<<Main>$>g__OuterAsync|0_0() in /Users/rich/git/build-talk-2026/runtime-async-demo/Program.cs:line 15
   at Program.<Main>$(String[] args) in /Users/rich/git/build-talk-2026/runtime-async-demo/Program.cs:line 10
   at Program.<Main>(String[] args)
   at System.Environment.CallEntryPoint(IntPtr entryPoint, String[]* pArgument, Int32* pReturnValue, Boolean captureException, Exception* pException)

.NET 11 (async v2 on):

dotnet run -f net11.0
.NET 11.0.0-preview.4.26230.115
Unhandled exception. System.InvalidOperationException: boom
   at Program.<<Main>$>g__MiddleAsync|0_1() in /Users/rich/git/build-talk-2026/runtime-async-demo/Program.cs:line 24
   at Program.<<Main>$>g__OuterAsync|0_0() in /Users/rich/git/build-talk-2026/runtime-async-demo/Program.cs:line 15
   at Program.<Main>$(String[] args) in /Users/rich/git/build-talk-2026/runtime-async-demo/Program.cs:line 10
--- End of stack trace from previous location ---
   at Program.<Main>(String[] args)
   at System.Environment.CallEntryPoint(IntPtr entryPoint, String[]* pArgument, Int32* pReturnValue, Boolean captureException, Exception* pException)

Both of the .NET 11 examples are different from the .NET 10 baseline.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions