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

其他回答

重置IIS,停止使用您的DLL的服务(可能是控制台应用程序或windows服务托管应用程序或IIS),然后尝试。

这对我很管用。

这发生在我使用IL支持插件时。

当您的项目中没有任何IL文件时(例如,因为您删除了最后一个文件),构建将失败,如问题中所述。

删除对IL的支持解决了这个问题

我也遇到过同样的问题,我尝试了这里提到的很多不同的方法,但没有一个对我有效,唯一对我有效的解决方案是:

从解决方案的DEBUG文件夹中删除READ ONLY属性 将此添加到构建事件:如果存在“$(TargetPath)”。$(TargetPath).locked" $(TargetPath)。锁定" if exists "$(TargetPath)" move "$(TargetPath)"“$(定位路径).locked”

我能够修复这个问题(VS 2010)通过提供以下预构建操作;

if exist "$(TargetPath).locked" del "$(TargetPath).locked"

if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

I experienced the error-messages when attempting to build the primary WinForms (XAF) project. I could only execute the application one time then needed to shutdown the VS2015 IDE and restart before a rebuild could be performed. After some digging in the project's property pages - in the "debug" property page, a check box was selected - Enable the Visual Studio Hosting Process. I unchecked and restarted the IDE, the application is now building without - "unable to copy the {project}.exe" messages.

Visual Studio托管过程的目的是什么?