在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

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

调试器设置为


当前回答

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

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

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

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

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

其他回答

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

[为我工作]

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

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

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

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

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

如果你使用Visual Studio Code (vsCode)遇到这个问题,或者你坚持使用终端命令,clean命令将删除构建文件,并通常修复描述的问题:

dotnet clean

然后,您可以返回运行:

dotnet build

or

dotnet run

@Gerard的答案是正确的。

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

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

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

> Add-Migration Initial
> Update-Database

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

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