4

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

Community
  • 1
  • 1
tbone
  • 5,715
  • 20
  • 87
  • 134
  • possible duplicate of [Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug](http://stackoverflow.com/questions/2895898/visual-studio-build-fails-unable-to-copy-exe-file-from-obj-debug-to-bin-debug) – tbone Feb 15 '11 at 16:13
  • However, my issue is not solved by the solution posted in the other question. – tbone Mar 01 '11 at 20:54

7 Answers7

4

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.

Kerem
  • 2,867
  • 24
  • 35
2

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.

Amogh Natu
  • 781
  • 1
  • 10
  • 37
1

If you are using Team Foundation Server, try closing Visual Studio and deleting everything in the TFS Cache subdirectory (e.g. C:\Users\\[login]\AppData\Local\Microsoft\Team Foundation\[version]\Cache).

The next time you launch Visual Studio it will complain about the missing configuration file, but one will be recreated when you reconnect to the TFS server.

Robin Daugherty
  • 7,115
  • 4
  • 45
  • 59
jerhewet
  • 1,186
  • 1
  • 10
  • 19
0

I've copied the parent folder of solution in another place in computer. After that, I rebuild the project and it works for me.

Darius
  • 31
  • 1
  • 2
0

I had the same problem.

It happened after i installed AVG antivirus. Just disable or uninstall AVG and the problem will be gone.

It can help te delete or replace te folder where your build is located and than rebuild the project.

Hope this helps!

0

It could be the anti-virus software on your machine sneaking in to check the new .exe file you just built, and thereby taking a read lock on the file for a short time. Try pausing the real-time virus scan on your machine temporarily and see if the problem goes away.

Jorgen Thelin
  • 1,066
  • 9
  • 23
0

Denied access is also a typical symptom when running VS as a user with lower privileges. Remember to run as administrator.

Turbo
  • 101
  • 1
  • 6