在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

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

调试器设置为


当前回答

对我来说,它是Avast反病毒,不让visual studio写入/读取/执行文件。所以我不得不将Visual studio 2010/2012文件夹添加到防病毒排除列表中。就在那之后……它的工作原理。

其他回答

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.

打开项目属性[菜单>项目>属性] 选择“调试”选项卡 取消勾选“启用visual studio托管进程” 启动调试[F5] 你会收到安全警告,只是“ok”。让应用程序运行 停止调试。 检查选项“启用visual studio托管进程”,在调试选项卡下, 现在,尝试开始调试,您将不会再次看到错误

[为我工作]

Use

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

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

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

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

这个问题是查找以下错误时的第一个结果:

无法复制文件“…”,因为没有找到该文件。

在Visual Studio 2013(更新3)中构建时。

解决方案:卸载Visual Studio 2013中的“生产力工具”。

https://connect.microsoft.com/VisualStudio/feedback/details/533411