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

其他回答

用款。我通过编辑MSBuild.Community.Tasks.Targets文件并更改bin路径解决了这个问题:

<MSBuildDnnBinPath Condition="'$(MSBuildDnnBinPath)' == ''">$(MSBuildProjectDirectory)\bin</MSBuildDnnBinPath>

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.

.vhost.exe是一个调试器进程,因此正在调试的进程似乎没有正确关闭。有可能你有一个错误,使它仍然存在,并且没有正确地停止调试进程——当你单击“停止调试”而不是实际杀死调试器时,有一些选项可以从进程中分离出来,所以也许你有这样的设置。

但这就是问题所在——你试图复制的文件被操作系统锁定(即仍在使用),所以它阻止了复制。确保该文件是免费的,您将能够复制。

我在Visual Studio 2013中遇到过类似的错误消息。

大多数情况下,我发现这种情况发生在调试进程因为异常而停止时。

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

关闭Visual Studio 删除bin和obj文件夹 重新开放Visual Studio。

此“bug”自Visual Studio 2003以来一直存在。

最后,我还发现我通常可以通过简单地重命名可执行文件然后删除它来克服这个问题。

我没有意识到我仍然连接着调试器,并试图在同一个Visual Studio实例中构建。一旦我停止调试器,我就能够构建。