Hi @Albertk ,
After restoring the project from a previous commit and putting back one controller at a time, and I finally found the issue. You see that there is a dangling semicolon below the using which cause the problem. The whole this is that it compiles ok and it even can be published but could not execute. Could someone confirm and raise a bug issue.
Microsoft Visual Studio Community 2019
using Microsoft.Extensions.Logging;
; // <= #### this is the offending line ####
I can reproduce the problem by creating a new Asp.net 5 API application via VS 2019 and add the semicolon.
When build the application, there is no build error, but if running the application, it will show the "HTTP Error 500.30 - ASP.NET Core app failed to start" error.
I also check it using VS 2022, create a new Asp.net 5 API application, and add the semicolon, when build the application, it directly displays a build error, like this:
So, this issue is the VS 2019 bug issue, and it has been solved in the VS 2022, you can report this problem to Visual Studio (refer to this article). And as a workaround, you can use the Visual Studio 2022 (download from here).
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion