在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

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

调试器设置为


当前回答

我找到了一个完整的解决方案!

大多数答案告诉你杀死进程,然而与进程黑客,我找不到任何。

我找到了一个相对简单的解决方案。

在窗体设计器中选择您的主窗体。 单击属性菜单上的事件选项卡。 双击事件FormClosing。这将自动生成事件系统和函数:

private void[你的表单名]_FormClosing(对象发送器,FormClosingEventArgs e)

在这个函数中,添加Application。退出

像这样:

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    Application.Exit();
}

有用的图像

我希望这能有所帮助!这道题真糟糕!

修复2

打开一项名为“应用体验”的服务。

其他回答

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

在任务管理器中检查任何运行.exe .exe的进程

在你的主项目taskkill /f /fi "pid gt 0" /im "YourProcess.vshost.exe"中添加预构建事件

对我来说,它是Avast反病毒,不让visual studio写入/读取/执行文件。所以我不得不将Visual studio 2010/2012文件夹添加到防病毒排除列表中。就在那之后……它的工作原理。

如果我使用VS2012在WP8上编辑Xaml页面,每次部署都会遇到这个问题。

我需要要么不打开Xaml页面,要么使用进程资源管理器杀死进程XDesProc.exe。

如果您得到这个错误,那么我建议使用进程资源管理器来查看发生了什么(即使这是一个不同的问题)。只要找到进程“WeinGartner.WeinCad.exe”,它应该显示进程和处理访问文件(好吧,至少当杀死vhost文件不解决问题)。