Click here to Skip to main content
15,123,367 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?
Updated 24-Sep-19 6:11am
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?
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.
Albert Holguin 7-Dec-11 14:57pm
Well, Visual Studio is the IDE, it's made up of different applications... if you close the IDE (Studio) a rogue process (let's say the debugger) may still be hanging.
Thomas Mack 7-Dec-11 14:35pm
[Window Title]

Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item.


OK - could this have anything to do with SlimDX or LUA? I'm running everything in X86 .NET 4.0
Albert Holguin 7-Dec-11 14:58pm
You are running Studio with admin privileges right?
Thomas Mack 7-Dec-11 16:59pm
Yes, of course. I have everything disabled (UAC) so everything for the most part runs as admin for me. I think it's LUA being stuck open. Tonight I am going to run each project separately and figure out what's going on, it's completely random.
Albert Holguin 8-Dec-11 9:24am
Good luck, this sounds like a headache... is it only happening with this project or is it also occurring with other projects?
Thomas Mack 8-Dec-11 12:04pm
It is. I got called into work so I haven't really messed it. I don't do much windows development mostly ASP.NET and this issue is non-existent but that all runs off my local IIS server... I'll mess with it when I get home today and if I find a solution I'll post it. I really think the LuaInterface DLL is hanging up. I'm going to remove the script execution and see if it continues to hang up. The DLL I found on a blog that was recompiled for .NET 4.0, so it might be that. The way it's acting seems like something is acting up. I have multiple projects:


Both project 1 and project 2 do the same thing, and they both are compiled with the DLL - but I've done this plenty of times and never had a issue.

And to think of it, NO, It doesn't happen on other projects. but what's confusing me is I've been having Windows Permission errors lately on my Windows 7. My OS is setup to have no security (UAC) features, so everything by default is ran as Administrator.. When I right click on the exe it says "Access is denied" I can't access ANYTHING on the EXE. Can't even change the read only properties or anything. When I right click, my computer shows a hour glass for about 30 seconds... Everything it's doing is so weird! After about 3 minutes, I can compile it with no problem. So it's giving me the feeling that SOMETHING is hanging and the only thing it can be is Lua...
Albert Holguin 7-Dec-11 9:17am
I haven't used VS2010 on Win7, but I know VS2008 had a lot of bugs running on Win7 that were odd before MS issued SP1 for VS2008. I'd imagine they wouldn't have those same issues with VS2010, but maybe look through the MSDN websites to see if anyone is having the same issues in case they've issued a hotfix.
[no name] 7-Dec-11 21:02pm
EDIT: added "pre" tag

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.
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.
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 rather than response here.

Thank you very much.

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
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!
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.
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"

maybe is you antivirus or firewall that block the new executable.
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.

Hi All! It's my antivirus "avast" is the problem! So go and give permission to needed path and voila!!!!
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.
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"

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.
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.

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 :)

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(>_<)
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
If it's getting blocked when trying to regenerate dlls/folders try deleting them manually. Worked for me.

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