在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

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

调试器设置为


当前回答

我注意到一些答案可以解决我的问题,但是,以防有人有和我一样的问题。

如果你正在运行一个控制台应用程序:在你做任何其他事情之前。

确保您已经关闭了从以前的版本中打开的任何控制台窗口。例如,我只是在一个控制台应用程序中测试一些代码,我没有意识到以前运行程序时的控制台窗口是打开的。在我调试的过程中,窗口被推到后面,我看不到它。只是说,这可能是你的问题,所以检查确保这不是问题。

其他回答

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.

进入“工具>>选项>>数据库工具>>常规” 检查脚本/查询执行情况

看看另一个答案。基本上,你可以让MSBuild.exe进程在后台运行,消耗资源文件。如果你有任何构建前或构建后的任务,导致MSBuild通过命令行启动,尝试添加"/nr:false"标志到这个命令。但是,关于更具体的细节,请参见前面的回答。

我以管理员的身份运行Visual Studio,设法解决了这个问题。

这发生在我使用IL支持插件时。

当您的项目中没有任何IL文件时(例如,因为您删除了最后一个文件),构建将失败,如问题中所述。

删除对IL的支持解决了这个问题