Question: Every time I start an Asp.Net 6 Application from the Console or Powershell, I get the error "Exited with error code -532462766".
Please Login to see the rest of the answer
Answer: This is because you have specified in the launchSettings.json file that the Profile of your Application Name running from the Console should run in Production Environment/Mode while you try to force/pass in Development as the Environment Variable when running Asp.Net 6 Application from the Powershell or Windows Terminal.
Steps to recreate.
1. Specify that you want the application to run in Production mode from the launchSettings.json
2. Force the Application to run in the Development Mode from the Windows Terminal or Powershell
3. Result will be "error code -532462766"
The solution to resolve the error:
1. Run the application in only one mode.
2. If you have defined the
then just type "dotnet watch run" in Windows Terminal or Powershell.
- Do not type "dotnet watch run --ASPNETCORE_ENVIRONMENT=Development" while you specify "ASPNETCORE_ENVIRONMENT": "Production" in the launchSettings.json.
I hope this helps you. Leave a comment if this does help you solve the error.
For me it was the applicationUrl section that has a real application Domain url, AspNet 6 could not start the application on https://www.something.com instead it needs to listen on https://0.0.0.0:5002.