Error: Cannot access file bin/Debug/… because it i

2019-01-03 22:39发布

When I debug my project, I get following error:

"Unable to copy file "obj\Debug\My Dream.exe" to "bin\Debug\My Dream.exe". The process cannot access the file 'bin\Debug\My Dream.exe' because it is being used by another process."

Using Process Explorer, I see that MyApplication.exe was out but System process still uses it although I stopped debug before. Whenever I change my code and start debug it is going to happen. If I copy project to USB and debug, it runs OK.

Why? How can I fix this error?

I use Window 7 Professional. With Xp I have never got this error.

26条回答
混吃等死
2楼-- · 2019-01-03 23:11

Worked for me. Task Manager -> Name of project -> End task. (i had 3 same processes with my project name);

VS 2013; Win 8;

查看更多
该账号已被封号
3楼-- · 2019-01-03 23:11

I have run to this same issue, and what I found is there are actually running mulitple Windows form application in the background. It happens when your application has two forms and you close the 2nd form which is not your main form so the application will not totally exited.

I usually run my application

  • through its exe or
  • run without debugging

Solution is close the other instance of Windows form application. This is one way to always close your application instance.

查看更多
三岁会撩人
4楼-- · 2019-01-03 23:12

I tried all these suggestions as well as other suggestions found elsewhere and the only thing that worked for me was restarting my computer. Then I did a clean solution followed by rebuilding. I am using Visual Studio 2013 for reference.

查看更多
smile是对你的礼貌
5楼-- · 2019-01-03 23:13

I had the same issue in Visual Studio 2013. I'm not sure what caused this for my project, but I was able to fix it by cleaning the solution and rebuilding it.

  1. Build > Clean Solution
  2. Build > Rebuild Solution
查看更多
男人必须洒脱
6楼-- · 2019-01-03 23:14

Close VisualStudio, ctrl-alt-delete, select Task Manager, find and end all MSBuild processes - VisualStudio basically has a pretty severe bug where it loses control of its debugger and the debugger maintains a lock on the .pdb file in the debug/bin folder. After you end all the MSBuild (debugger) processes, delete the /debug/bin folder and reopen your solution in Visual Studio. You're good to go now. Microsoft needs to fix this crap.

查看更多
爷的心禁止访问
7楼-- · 2019-01-03 23:15

Pre build command

(if exist "$(TargetDir)*old.pdb" del "$(TargetDir)*old.pdb") & (if exist "$(TargetDir)*.pdb" ren "$(TargetDir)*.pdb" *.old.pdb)

Helped

查看更多
登录 后发表回答