Click here to Skip to main content
15,883,796 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Alright, I've given up on everything. I am working on multiple applications. I can't seem to find the proper way to get this working. No matter WHAT I do, I get access denied errors. I've switched user accounts on Windows 7, I've reset permissions, etc.

Sometimes the project will compile and run fine. I'll edit some code, and hit F5 and it'll say "Unable to copy file to file" etc. I'll delete the file and sometimes it'll work. But it's getting worse - after I delete the file and I hit "F5" it'll show a quick loading cursor then nothing happens. The project doesn't even attempt to start. If I wait 5 minutes and hit F5, it'll start right up no issues.
Error	2	Unable to copy file "obj\x86\Debug\project.exe" to "bin\Debug\project.exe". Access to the path 'bin\Debug\project.exe' is denied.


Checking the task manager, the application isn't stuck open. Nothing is excessively stealing RAM or CPU. The app open and closes fine.
Error	1	Unable to copy file "obj\x86\Debug\project.exe" to "bin\Debug\project.exe". The process cannot access the file 'bin\Debug\project.exe' because it is being used by another process.	

ANY kinds of ideas? I'm seriously giving up on it! It's killed me all night and slowed me down. My code is pointing to a blank form. I've removed ALL code. Same issue. This is .NET framework 4.0 x86.

When I delete the file, and hit F5, that's when I get the error. Sometimes it won't open. It's random. I'm using a fresh version of VS 2010 with latest updates SP1 (ultimate)

The weird thing is when it gets access denied, Windows denies my access 100%! I can't run it (gives a error, sorry didn't save it) and I can't delete the file. When I right click and go to security, it says access is denied. I've been getting weird security positions on my Windows 7 install lately - could this be related?
Posted
Updated 24-Sep-19 5:11am
v4
Comments
Sergey Alexandrovich Kryukov 7-Dec-11 5:32am    
Can you possible reduce the code to the size suitable to post in your question (use "Improve question") so it would still show the problem?
--SA
Thomas Mack 7-Dec-11 11:02am    
The code is a basic form layout that comes default, I've removed the little bit of code. I started the project yesterday.
Albert Holguin 7-Dec-11 13:50pm    
Something has to be tying up the file (maybe some IDE component that's failing)... there's a way to see what process has the file locked, can't remember off the top of my head, but try searching google for a way to do that. Then next time it locks up, see what's locking up access to the file.
Thomas Mack 7-Dec-11 14:01pm    
This is a good idea.. Was it called unlocker? I have that installed, but it says it's not locked =X
Thomas Mack 7-Dec-11 14:33pm    
OK if I close and reopen Visual Studio it says the file is still locked.

Check your task manager and see if the project.exe or project.vhost.exe is running.

If this is the case then your application is not closing properly.
 
Share this answer
 
Comments
Thomas Mack 7-Dec-11 5:30am    
I've already done that, they are not running. When you run VS in debug mode if you goto "Stop Debug" the application is forced closed no matter what. No rogue app is running to cause this issue. That's why I'm confused.
I'm not 100% sure what/why, but I created a whole new project, added coded manually, same thing. Removed references nothing. I set the start up project as the EXE project (rather then the solution->selecting the startup project there) and it seems to work.

So it's working now.. no clue why, must be a bug? Maybe it wasn't compiling and linking the DLL project, not sure.
 
Share this answer
 
v2
Comments
Albert Holguin 9-Dec-11 14:40pm    
Interesting... I'd have to look at your project to see if there was a dependency problem. Well, at least you're up and running again. Cheers!
kero6417 10-Apr-12 18:45pm    
I met exactly the same situation as you described. I tried all means, hours of googling to get rid of that; but it still occasionally showing. I agree with you that it should be something related with the windows 7 security issue. as what you mentioned when access the Property/Security Tab. As you said, "I've been getting weird security positions on my Windows 7 install lately ", could you list what kind of security position you have got? I really want to find the root reason and close this issue.

you can also reach me at pwang.ms@gmail.com rather than response here.

Thank you very much.

Peng.
Thomas Mack 10-Apr-12 21:44pm    
I never did figure out. I meant to say permission, not position as well. I've been getting a lot of Access Denied errors on my Win7 box. I got fed up with the issues, that I formatted my PC. Once I formatted and reinstalled Windows 7, the issue went away completely. I don't know what caused it. Somewhere, somehow, Windows 7 messed up the permissions. Perhaps a undetected rogue application did it, perhaps it's a glitch with Windows 7 that over time the permissions get messed up.

So somewhere I had an issue, not sure where. But other then that, this issue is technically resolved but the actual fix is unknown. The only known fix right now is to format and reinstall Windows 7.
kero6417 11-Apr-12 12:22pm    
Yes, I think i have to agree with what you said. Finally, I have to turn to our network team for help to reinstall windows 7.

Thank you for your reply.
Finally I know how to solve this problem. After 2 days google-ing..

Turn on windows service :- Application experience


Computer (right-click) -> manage -> Service & Application -> service -> Enable Application experience

Works for me.. hope it helps
 
Share this answer
 
Comments
cubrman 29-Apr-13 15:10pm    
Like, TOTALLY helped me)
harley7988 9-Oct-13 14:07pm    
This problem recently popped up for me again after I solved it years ago. Unfortunately, I forgot how I solved it. Seeing this solution, I remember this was the answer then and now. Not sure why, this service shouldn't have anything to do with when my files are unlocked, but hey. Thanks for the reminder!!
ofirn 15-Jan-15 6:42am    
Helped me alot - thanks :-)
after this service was disabled, I searched hours for a solution to this problem and was focusing on pre-build scripts that did not help (access denied errors to file ownership or delete). I wonder what is the connection to this service?!
**** Microsoft...
dean9359 26-Oct-16 18:43pm    
I've had this problem on Windows 7 and the same on Windows 10. Just lived with it until I read this solution. Thank you!!
My solution is:

Clean solution followed by rebuild was resulting in top.exe not copying from obj to bin directory. The claim was top.exe as being used by another process. I used task manager to check for the usual suspects and found it to look clean. Manually deleting using windows explorer, hover, worked. Clean rebuild then worked fine. Another clean rebuild, however, resulting in top.exe not copying from obj to bin directory again with same complaint.

After a frustrating hour+, I discovered that msvsmon.exe was running. This turns out to be the remote debugger monitor. (Duh! I had been using this a while ago and did not realize it was running.)

After killing msvsmon process tree using task manager, birds are singing again.

Hope this helps someone else!
 
Share this answer
 
Comments
RedDk 17-Jun-16 12:55pm    
Hope you're right! (nope ... running msvsmon (sometimes it does, sometimes it doesn't depending on the cascade of errors) ... not the solution)
No real solution was found. I ended up reinstalling Windows 7. I was getting access denied errors with several different things, not just Visual studio. VS2010 was the most affected, though. The only solution known is to reinstall Windows.
 
Share this answer
 
I was getting 'Unable to start program "http://localhost:51351/". Access is denied.'
This only happened with F5 (Start Debugging). A browser window would open and hang, and had to use Task Manager to kill it.
However, Ctrl-F5 (Start Without Debugging) worked ok.

We originally tried running VS with full admin privileges and that did not help.

We think these 3 things fixed it:
1) moved the project from a network drive to c: drive.
2) gave me full admin rights to the whole visual studio folder system.
3) changed setting in web.config:
in the system.web section, add: compilation debug="true"

HTH
Mike
 
Share this answer
 
v2
maybe is you antivirus or firewall that block the new executable.
 
Share this answer
 
Comments
maryjainpa 17-Feb-16 7:36am    
Correct answer my system avast anti virus was blocking the execution of web application in visual studio.
I added the project path in exclusion folder list of avast. After that issue was solved.
Kadam Ganesh 28-Nov-16 2:41am    
Yes. I disconnected VPN and I solved my issue.I was getting below issue due to VPN.

Unable to copy file "\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.xml" to "bin\Debug\EntityFramework.xml". Access to the path 'bin\Debug\EntityFramework.xml' is denied.
Member 15061957 1-Feb-21 16:10pm    
yes i have that problem how can i solve it plz help. My antivirus is creating a problem in running the program
There are obviously various things that can "Fix" this Bug.

What sometimes works for me, is closing the solution, then reopening it and rebuilding...

Not sure if it will work all the time.

Thanks
 
Share this answer
 
Hi All! It's my antivirus "avast" is the problem! So go and give permission to needed path and voila!!!!
 
Share this answer
 
Comments
Member 15061957 1-Feb-21 16:19pm    
how to do that? Can u explain step wise plz
Hi Bros :
I had the same problem.
I created a new project and copied all code to my new project and everything is ok after that.
 
Share this answer
 
Solved by adding this script in all projects (exe/dll) in the solution in their respective Pre-build events:

if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
 
Share this answer
 
v2
Hi,

Check that you have all the permission to make the appropriate modifications.

And alos check whether the folder / file / solution is marked as ReadOnly. If maked readonly please unchek and rebuild the solution.
 
Share this answer
 
Comments
naelnael 27-Sep-13 17:36pm    
can you illustrate your comment ?
what to click ?
cerfus 16-Mar-16 15:31pm    
This one worked for me, sometimes when you download the code from the source code version control all the folders and subfolders are marked ReadOnly, I right clicked on the solution folder and unmarked ReadOnly [apply to all subfolders] and now it's working.
Hi,

Right-click on the solution then choose 'Clean Solution'. Then right-click on the solution again, then choose 'Rebuid Solution'. Then 'Build Solution'.

Let me know if this doesn't work :)

Regards,
Eduard
 
Share this answer
 
Comments
Thomas Mack 8-Dec-11 0:27am    
I wish it was that easy :'( I've done this tons of times. It has to be the LuaInterface being stuck open, that's the only thing I can think of.
I found that the way to fix the issue is to go to the folder containing the exe that your program is attempting to replace, right click on it and under the general tab uncheck the read only property.

This worked for my program. I do not know why or how the folder became read only, i only know how to undo it.

Hope this helps(>_<)
 
Share this answer
 
This issue has been RESOLVED by REINSTALLING WINDOWS.
 
Share this answer
 
Hi everyone. My Solution is:
In VS menu -> Tools -> Options -> Projects and Solution -> Build and Run -> and "set maximum number of parallel builds" to 1.

Hope this helps
 
Share this answer
 
If it's getting blocked when trying to regenerate dlls/folders try deleting them manually. Worked for me.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900