Unable to start Console App – Access Denied

Share This Post

To quickly test some code, we created a console application. Only it would not start because of an access denied error. I have never seen this error message before. Could it be a problem with the Visual Studio program or debugger? We will find out in this blog post!

Details of the error

First, we would like to discuss the error message, today we received an error message (when we start debugging) that the “project.exe” could not be executed due to an Access Denied (see screenshot).


So we have a major problem, the console app won’t start so we can’t test or debug our code.
When the error came up for the first time I had the reaction to try with the dotnet CLI and create and build a new project from scratch. Unfortunately without any success :(.

How can i resolve this problem? (aka the solution)

After some research, I have come to the conclusion that Microsoft Windows Antivirus is causing the problem.
The Windows AV ensures that the “[name].exe” is blocked. However, I had expected a different message than Access Denied, but AV is blocking the execution of the program.

The only (secure) solution to this problem is to whitelist the Visual Studio programmes responsible for debugging (see screenshot below).

Go to Windows Security > Virus & threat protection settings > Exclussions and add the programmes to the list.

Another good alternative from a security perspective is to exclude a folder where the development project are created. Give the folder an illogical name so hackers can’t guess the name and drop their exe files into the folder. The risk here is that all exe files in this folder will be execuded without any check of the Antivirus.

Conclusion

Microsoft does not take their own products into account and will mark the exe files generated by their development tools as potential danger. Very strang, but high secure ­čÖé so keep this in mind! In my case this problem was related to Visual Studio but it could be that the next problem you or I face is with executing PowerShell scripts.

Happy coding!

More info: Adds Windows Defender exclusions for Visual Studio 2019 ┬Ě GitHub

More To Explore

Failed to start the Application Gateway

When setting up an Application Gateway (AGW), the public and private IP addresses of the Application Gateway are required in order to complete the configuration.