Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access denied error when trying to build VS2010 console application (Could not write to output file )

VS2010 running on Windows7x64

I am trying to do a build of a VS2010 console application, and sporadically get this error:

Could not write to output file 
'D:\somepath\someProjectName\obj\Debug\ProjectName.exe' -- 'Access is denied. ' 

Using Sysinternals ProcessExplorer, I can see a handle to that file, but when I click on it, no application is shown holding it, and when I try to close the handle, I get a "Error opening process: the handle is invalid." error in ProcessExplorer.

If I go to the folder in windows explorer, I can physically delete the file (so it seems), but the lock still persists, making me think it perhaps didn't actually delete, perhaps it is just pending deletion?

Is this a known bug, something I am doing wrong, other?
Is there a utility that can force this file to be unlocked?

See here for possible solutions:
Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug

like image 324
tbone Avatar asked Sep 18 '25 10:09

tbone


2 Answers

I was having the same problem and it was AVG Resident Shield for me scanning files as they are copied, opened or saved. After disabling it temporarily my problem is gone.

like image 139
Kerem Avatar answered Sep 20 '25 05:09

Kerem


I got the same problem when I was building a setup project and VS was not able to delete the previously built .msi

I deleted it myself explicitly and tried to build the setup project again and it worked.

like image 41
Amogh Natu Avatar answered Sep 20 '25 05:09

Amogh Natu