在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.

其他回答

将此添加到预构建:

(if exist "$(TargetDir)*old.exe" del "$(TargetDir)*old.exe") & (if exist "$(TargetDir)*.exe" ren "$(TargetDir)*.exe" *.old.exe)

我通过在任务管理器中杀死IISExpress解决了这个问题

在Visual Studio 2010中,我也会定期遇到这个问题。关闭Visual Studio,删除bin和obj目录,并重新启动将修复一个构建。然后问题又回来了。我已经尝试了这个帖子上的所有其他答案,但没有一个对我有效。对我来说,唯一能永久解决这个问题的方法就是打开项目设置,关闭“启用Visual Studio托管进程”,构建,再打开,然后再次构建。

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

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