在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

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

调试器设置为


当前回答

此问题通常在运行测试时发生。如果这是你的情况,只需转到任务管理器并杀死testHost

其他回答

请确保关闭所有wcfSvcHost实例,然后重试。 这对我很管用!

您可以通过脚本终止应用程序。

如果你的应用程序名为myapp.exe,在终端中运行下一个脚本:

taskkill /IM myapp.exe /F

参数为:

/IM   application name (imagename)

 /F                     Specifies to forcefully terminate the process(es).

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

这对我很管用。

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.

我通过在任务管理器中杀死IISExpress解决了这个问题