在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

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

调试器设置为


当前回答

Use

Debug.Flush();
Debug.Close();

如果发生异常,则在catch或finally中阻塞。

编辑: 我个人遇到过这个问题,我通常会做一个小技巧,效果很好。 我将构建类型从“调试”更改为“发布”(如果已经存在,则将“发布”更改为“调试”)。

其他回答

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

对我来说,杀死vste .executionengine.exe进程(es)在90%的情况下解决了这个问题。如果这不起作用,那么也杀死QTAgent32.exe,然后删除项目的/bin和/obj文件夹。

这是我工作中最烦人的部分。:)

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.

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

如果我使用VS2012在WP8上编辑Xaml页面,每次部署都会遇到这个问题。

我需要要么不打开Xaml页面,要么使用进程资源管理器杀死进程XDesProc.exe。

如果您得到这个错误,那么我建议使用进程资源管理器来查看发生了什么(即使这是一个不同的问题)。只要找到进程“WeinGartner.WeinCad.exe”,它应该显示进程和处理访问文件(好吧,至少当杀死vhost文件不解决问题)。