在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”
你很好!
第一个消息错误解决方案:
在我的例子中,问题在于路径长度。
解决方案是减少/更改问题文件路径。如果问题出在项目中的文件上,你应该减少/更改存储库路径。
C:\Users\userTest\folder1\folder2\folder3\...\folderX\myProject\...\file.exe
如。
C:\Users\userTest\folder1\myProject\...\file.exe
换句话说,默认情况下路径长度不能超过260个字符。
原线程答案
(https://stackoverflow.com/a/73686473/12678101)