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 was able to fix this issue (VS 2010) through supplying following pre build action;
Make sure u close all instances wcfSvcHost and try again. It worked for me!
I faced the same problem on VS 2012 Version 11.0.60610.01 Update 3 on Windows 8
There were no designer windows open and the project was a simple console application.
The removal of the vshost process accessing the file does not work most of the time since the process isn't accessing the file.
The simplest workaround that works and takes the least amount of time is to remove the project from the solution, build another project in the solution and then add the original back.
It's an irritant and waste of time but it's the least expensive of all the other options that I know of.
Hope this helps...
[Work for me]
If none of the answers works, try this simple check. Find for any MSbuild.exe running and holding your project EXE. Kill MSBuild.exe and you should be good to go.
Follow the below steps
Above steps resolved error permanently :)