The problem is due to a bug in the way the debugger interacts with CET. The error goes away when the following line is added to the project file:
<CetCompat>false</CetCompat>
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm using Visual Studio 2022 (17.12.0 - preview 1.0)
I noticed that .NET 9 is now available as an option in Visual Studio 2022 so I tried upgrading from .NET 8. My applications continue to run as expected, with one problem: I'm getting a fatal error when halting my console applications using Control-C, or when closing the console using the X close button in the upper right corner.
Here's the error I'm receiving:
This applies to all of my console applications that make use of the WebBuilder
class. The simplest program that will consistently trigger the error is:
internal class Startup
{
public static async Task Main(string[] args)
{
await WebApplication.CreateBuilder().Build().RunAsync();
}
}
This code was entered into a new console project, in a new solution, where the top line in the project file has been changed to:
<Project Sdk="Microsoft.NET.Sdk.Web">
In addition, launchsettings.json has been deleted to prevent Brave browser from launching when the app is run. The error still occurs even if this file is present; I just deleted it to remove Brave from the equation.
The app itself works fine. It's only the shutdown, when triggered by Control-C or clicking the close button (X) in the console window, that immediately triggers a fatal error with no hints written to the Event Log.
Interestingly, when the app shuts itself down using IHostApplicationLifetime.StopApplication
, the shutdown is smooth. There are no errors.
Running the application from the Powershell command line instead of the debugger causes the error to go away. The error only manifests when the debugger is attached.
Reverting the project from .NET 9 back to .NET 8 also causes the error to go away.
Googling this particular error turns up nothing. Any ideas?
The problem is due to a bug in the way the debugger interacts with CET. The error goes away when the following line is added to the project file:
<CetCompat>false</CetCompat>