I keep getting this error during the build of my VS2012 C# project
Error 41 Could not copy "obj\Debug\WeinGartner.WeinCad.exe" to
"bin\Debug\WeinGartner.WeinCad.exe".
Exceeded retry count of 10. Failed.
Error 42 Unable to copy file "obj\Debug\WeinGartner.WeinCad.exe" to
"bin\Debug\WeinGartner.WeinCad.exe". The process cannot access the file
'bin\Debug\WeinGartner.WeinCad.exe' because it is being used by another
process.
Now I've figured out that killing the process
Weingartner.WeinCad.vhost.exe
works (sometimes ) but this is getting on my nerves. Any way to stop this happening at all?
My debugger settings are
I think I solved it removing the check mark to
Break all processes when one process breaks
in Debug options (op's first screenshot->second option).It's been building/running well for a while since I unchecked it.
I'm using MySql NET Connector and DevExpress controls in my project. May be one of them was not disposing connections, bindings, etc. well because of this flag beeing activated.
EDITED: definitely it works! No more 'Unable to copy file' and no more Form designer errors.
I didn't realize I still had my debugger attached and was trying to build in the same Visual Studio instance. Once I stopped the debugger I was able to build.
I have solved it by killing IISExpress in task manager
My 10 cents contribution.
I still have this problem occasionally on VS 2015 Update 2.
I found that switching compilation target solves the problem.
Try this: if you are in DEBUG switch to RELEASE and build, then back to DEBUG. The problem is gone.
Stefano
In Visual Studio Premium 2013 (Update 3), I solved this with a pre-build one-liner:
This gracefully deletes any old PDB files (if it can), then renames anything that's left with a
.old.pdb
extension. A nice side effect is that if the old PDB is still locked, it just adds another .old piece to the filename, and they all get cleaned up next time you restart Visual Studio and do a build.For example, build/debug session 1 leaves
MyProject.pdb
locked.The next time you build:
MyProject.pdb
-->MyProject.old.pdb
Then, build/debug session 2 is started, and both
MyProject.pdb
andMyProject.old.pdb
are still locked:MyProject.old.pdb
-->MyProject.old.old.pdb
MyProject.pdb
-->MyProject.old.pdb
Finally, restarting Visual Studio and doing a fresh build will get rid of both of these, and continue the process as usual.
This question was the first result when looking for the following error:
when building in Visual Studio 2013 (Update 3).
Solution: Uninstalling the "Productivity Power Tools" in Visual Studio 2013.
https://connect.microsoft.com/VisualStudio/feedback/details/533411