在VS2012 c#项目的构建过程中,我一直得到这个错误

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.    

现在我知道该终止进程了

Weingartner.WeinCad.vhost.exe

(有时)有用,但这让我很紧张。有办法阻止这一切发生吗?

调试器设置为


当前回答

花了几个小时试图解决这个问题,然后发现我正在处理一个服务-记住停止任何服务作为解决方案的一部分!

其他回答

如果您正在调试T4模板,那么这种情况经常发生。我的解决方案(在MS修复这个问题之前)将只是杀死这个进程:

任务管理器—> User—> T4VSHostProcess.exe

此过程仅在调试T4模板时出现,而不会在运行T4模板时出现。

引用:

一个解决方法是把它放在>项目的预构建事件命令行属性中(在构建事件选项卡中):

代码片段

if exist "$(TargetPath).locked" del "$(TargetPath).locked"

if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

I ran into this as well. It turns out that I had been testing with a service which I had built myself and which was running out the of the ..\bin\release directory of one of the projects in my solution. I had got the service running, but I forget to stop/uninstall it before returning to testing. As a result, it was holding on to one of the dlls that I reference and which needed to be moved (automatically as a dependency) from one project's bin/release subfolders to another. Stopping the service solved the problem.

我已经添加了不同次相同的问题,从这个治疗没有一个答案可以帮助,或者如果他们这样做了,使用一个讨厌的工作。 我认为这个问题总是有一个很好的原因发生(不是微软的bug!)-好吧,不过VS在标记方面可以做得更好:-))。

主要原因可能只是你的项目依赖关系搞砸了! 作为一个简单的例子():

在同一个解决方案中有多个项目 你清理+构建所有,并假设一切都很顺利,因为你没有看到错误 您开始运行其中一个项目—到目前为止一切正常! 然后开始运行第二个项目,但这个项目也有前一个项目使用的依赖项,并尝试重新构建它们 然后挂一段时间 它无法在第一个项目已经运行时进行构建,并且不允许您覆盖正在进行的流程

现在,您可以想到所有可能触发此类错误的场景:

Error Could not copy "obj\Debug\ProjectX.exe" to "..\bin\Debug\ProjectX.exe". Exceeded retry count of 10. Failed. The file is locked by: "ProjectX (17132)" ProjectX

修复这个问题通常是一个乏味的过程,因为您必须完全理解系统中的所有依赖项

花了几个小时试图解决这个问题,然后发现我正在处理一个服务-记住停止任何服务作为解决方案的一部分!