在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

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

调试器设置为


当前回答

我正在研究一个微服务项目解决方案,我需要同时运行两个项目,冲突发生在lunchsettings.json applicationurl: {portNo}部分用于两个正在运行的项目是相同的端口

lunchsettings。第一个项目的Json

...
"Project#1": {
  ...
  "applicationUrl": "http://localhost:5001",
  ...
}

lunchsettings。第二个项目的Json

...
"Project#2": {
  ...
  "applicationUrl": "http://localhost:5001",
  ...
}

来修复它

lunchsettings。第一个项目的Json

...
"Project#1": {
  ...
  "applicationUrl": "http://localhost:5001",
  ...
}

lunchsettings。Json for secondproject

...
"Project#2": {
  ...
  "applicationUrl": "http://localhost:5002",
  ...
}

其他回答

遵循以下步骤

打开任务管理器(Ctrl + Alt + Delete) 在Performance选项卡下选择<ProjectNameOfYours.exe>。 单击End Process。 现在构建解决方案。

以上步骤永久地解决了错误。

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

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

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

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

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

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

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

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.