在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

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

调试器设置为


当前回答

@Gerard的答案是正确的。

当clean+build不能为我解决这个问题时,我通过以下方法取得了成功:

Closing Visual Studio
Deleting the bin and obj folders, and
Reopening Visual Studio.

但我需要在主机上做一些额外的工作:

> Add-Migration Initial
> Update-Database

然后我开始调试,它起作用了。

其他回答

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

我终于怎么修了。为什么我们不能在第一次调试后继续调试,因为第一次调试exe仍在运行。这样,在第一次调试之后,您需要进入任务管理器->进程选项卡->[您的项目名称exe]结束exe进程。

这对我很有用:)

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

删除Bin文件夹中的Debug或Release文件夹下的所有.cache文件。

最快的方法是更改Build配置类型并再次返回到以前的配置。