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

其他回答

在任务管理器中检查任何运行.exe .exe的进程

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

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

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

重置IIS,停止使用您的DLL的服务(可能是控制台应用程序或windows服务托管应用程序或IIS),然后尝试。

这对我很管用。