在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 2013(更新3)中构建时。

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

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

这是因为你已经关闭了你的应用程序,但它仍然在后台运行。

临时解决方案:

进入任务管理器(Ctrl + Shift + Esc)。 进入进程选项卡,找到“YourProjectName.exe”。 如果找不到自己的进程,请勾选“显示来自所有用户的进程”。 结束处理

永久解决方案:必须通过编码关闭应用程序。这是代码…

System.Windows.Forms.Application.Exit();

您必须以所有形式将此代码放入表单的关闭事件中。例子:

private void frm_menu_FormClosing(object sender, FormClosingEventArgs e)
{
    System.Windows.Forms.Application.Exit();
}

我在VS 2015中遇到了这个问题。我的环境的原因是使用StyleCop项目设置StyleCopAdditionalAddinPaths Include="…"来指定额外的StyleCop Addin路径。我使用的变通方法是从.csproj文件中删除这个项目设置,取而代之的是手动复制StyleCop AddIn中的StyleCop. csharp . rules .dll。不是一个优雅的解决方案,但我发现解决方案从来没有锁定dll之后,这样做。

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

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

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

在我的案例中,Visual Studio 2105远程调试器是问题所在。当我在任务管理器中杀死这个任务时,我能够成功地在Visual Studio中重建我的应用程序。