在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

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

调试器设置为


当前回答

请确保关闭所有wcfSvcHost实例,然后重试。 这对我很管用!

其他回答

我意识到这只是为这个问题增加了一个已经非常多的答案,但我认为值得一提的是,尽管不完美,但@Stefano, @MichaelRibbons和@IvanFerrerVilla给出的答案的组合已经提供了一些不错的成功,因为他们各自都不太成功。

I experienced the error-messages when attempting to build the primary WinForms (XAF) project. I could only execute the application one time then needed to shutdown the VS2015 IDE and restart before a rebuild could be performed. After some digging in the project's property pages - in the "debug" property page, a check box was selected - Enable the Visual Studio Hosting Process. I unchecked and restarted the IDE, the application is now building without - "unable to copy the {project}.exe" messages.

Visual Studio托管过程的目的是什么?

此问题通常在运行测试时发生。如果这是你的情况,只需转到任务管理器并杀死testHost

我终于怎么修了。为什么我们不能在第一次调试后继续调试,因为第一次调试exe仍在运行。这样,在第一次调试之后,您需要进入任务管理器->进程选项卡->[您的项目名称exe]结束exe进程。

这对我很有用:)

我已经添加了不同次相同的问题,从这个治疗没有一个答案可以帮助,或者如果他们这样做了,使用一个讨厌的工作。 我认为这个问题总是有一个很好的原因发生(不是微软的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

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