'Unable to start program, access is denied
Solution 1:[1]
You are trying to "execute" the "ALL_BUILD" folder rather than your program; a folder can't be executed.
Check your program's project properties and ensure that the "Command" you want to debug actually points to the compiled 'exe' file or $(TargetPath) and ensure that you have the correct start-up project selected.
Solution 2:[2]
As I just wasted 20mins chasing this same problem... I'll augment this thread with a different reason for the access denied issue.
The culprit was my Anti Virus. Mc**** kept thinking my newly built .exe was malicious and quarantined it (SILENTLY!) Also, if you ever notice the final link of the .exe seems slow, it probably is, because the file gets a Virus scan when it appears. So, every time you debug you lose a second of your life.
AntiVirus -> Change Settings -> Real-Time scanning -> Excluded Files -> Add
Add your Debug and Release targets.
Solution 3:[3]
It is because you didn't set start project you want. right click the project you want to debug, and then click set as StartUp Project. This will solve your problem.
Solution 4:[4]
This happens due to permissions issue in your machine.
so get permissions added . in my case due to time crunch i just relocated my project to visual studio projects path and that worked correctly.
example Path for VS2019
C:\Users\UserName\source\repos\YourProject
Solution 5:[5]
Having had the same problem, only thing that fixed it for me was to add my source folder to the Excluded Folders from Windows Defender Threat Protection (in Win10 security settings).
Solution 6:[6]
I'm Brazilian, I don't speak English very well. I did this translation on google translator. I know the topic is old, but it can still help someone. I had this same problem in the following situation, but with C#, I have a dual boot computer (linux debian 11 and windows 10). Inside debian, on my NTFS D disk, I created a folder to perform programming tests. After accessing that same folder with windows, I created a new project in visual studio inside that same folder that I had created in linux. The creation of the project went without problems, however when I tried to run the project (F5), I received the same error from this topic. I tried all the solutions I found on the internet, and nothing worked. I gave all permissions to my admin user and it still didn't work. Then I realized that even going straight to the folder where the application's executable was and clicking directly on it, I still received the access denied error message. So, I took the project out of the folder I had created in linux, and it worked. So, what I could conclude, is that because the folder where my project was was created in linux, for some reason, my windows didn't trust this folder, so it didn't allow running executables from inside that folder, even this one executable having been created by visual studio from within windows.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | J.R. |
| Solution 2 | user1970907 |
| Solution 3 | Jie Yin |
| Solution 4 | sajad |
| Solution 5 | henrikh_ |
| Solution 6 | Dharman |

