在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

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

调试器设置为


当前回答

异常

在某些情况下,在Visual Studio当你(Build || Rebuild)在上面 运行IISExpress时,你会遇到这个异常:

无法复制文件"obj\Debug\YourProjectName.dll"到bin\YourProjectName.dll"。进程无法访问该文件 'bin\YourProjectName.dll',因为它正在被其他人使用 过程

解决方案

右键单击需要构建的web项目。 单击属性。 在左侧选择Build Events选项卡。 在Pre-build events命令行中粘贴这两行:

tasklist /fi “imagename eq iisexpress.exe” |find “:” > NUL 如果错误级别 1 任务杀死 /f /im “iisexpress.exe”

你很好!

其他回答

我没有意识到我仍然连接着调试器,并试图在同一个Visual Studio实例中构建。一旦我停止调试器,我就能够构建。

这个问题是查找以下错误时的第一个结果:

无法复制文件“…”,因为没有找到该文件。

在Visual Studio 2013(更新3)中构建时。

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

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

删除Bin文件夹中的Debug或Release文件夹下的所有.cache文件。

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

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

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

对我来说,杀死vste .executionengine.exe进程(es)在90%的情况下解决了这个问题。如果这不起作用,那么也杀死QTAgent32.exe,然后删除项目的/bin和/obj文件夹。

这是我工作中最烦人的部分。:)