在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

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

调试器设置为


当前回答

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托管过程的目的是什么?

其他回答

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

如果您正在调试T4模板,那么这种情况经常发生。我的解决方案(在MS修复这个问题之前)将只是杀死这个进程:

任务管理器—> User—> T4VSHostProcess.exe

此过程仅在调试T4模板时出现,而不会在运行T4模板时出现。

第一个消息错误解决方案:

在我的例子中,问题在于路径长度。

解决方案是减少/更改问题文件路径。如果问题出在项目中的文件上,你应该减少/更改存储库路径。

C:\Users\userTest\folder1\folder2\folder3\...\folderX\myProject\...\file.exe

如。

C:\Users\userTest\folder1\myProject\...\file.exe

换句话说,默认情况下路径长度不能超过260个字符。

原线程答案 (https://stackoverflow.com/a/73686473/12678101)

我以管理员的身份运行Visual Studio,设法解决了这个问题。

我在Windows 8上的VS 2012 Version 11.0.60610.01 Update 3上遇到了同样的问题

没有打开设计器窗口,项目是一个简单的控制台应用程序。

删除访问该文件的vshost进程在大多数情况下都不起作用,因为该进程没有访问该文件。

最简单的工作方法是将项目从解决方案中删除,在解决方案中构建另一个项目,然后将原始项目添加回来。

这是一种刺激和浪费时间,但这是我所知道的所有其他选择中最便宜的。

希望这对你有所帮助……