0
votes

I meet this question often. Why does it happen?

Screenshot of Visual Studio Error List

The two errors shown in Visual Studio say:

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

and

Could not copy "obj\Debug\DeRs2.exe" to ""bin\Debug\DeRs2.exe". Exceeded retry count of 10. Failed.

1
Sometimes the executable is locked by Visual Studio threads. Close and reopen Visual Studio is the way to fix. - Lex Li
Thanks very much @LexLi - SSadig
It could mean that the executable VS is trying to build is currently running. Have you launched it by Control-clicking the Start button or double-clicking the .exe file in File Explorer? - adv12
@adv12 I launched it normally. If I copy all my codes to new file it will work but I don't understand why this happen? - SSadig
1>------ Build started: Project: Rengler, Configuration: Debug Any CPU ----1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(3813,5): warning MSB3026: Could not copy "obj\Debug\Rengler.exe" to "bin\Debug\Rengler.exe". Beginning retry 1 in 1000ms. The process cannot access the file 'bin\Debug\Rengler.exe' because it is being used by another process.========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== - SSadig

1 Answers

1
votes

Is the output program still running? If a program is running, windows flags it's executable file as 'in use', and won't let anyone or any program delete or modify it. So, if you started the program manually and it is still open (or if it doesn't close properly and is still hanging around in the background in Task Manager) then you will get this error.

If you let Visual Studio run the program for you then it will automatically force the program to close when you need to rebuild. It also provides lots of debugging tools and even lets you change the code while the program is running.