我有一个 C# 项目,每次我尝试编译该项目时都会收到此错误:
(Unable to copy file "obj\Debug\Project1.exe" to "bin\Debug\Project1.exe". The process cannot access the file 'bin\Debug\Project1.exe' because it is being used by another process.)
所以我必须从任务管理器中关闭进程。我的项目只有一种形式,没有多线程。
解决方案是什么(不重启 VS 或终止进程)?
最佳答案
这应该有效。
转到您的项目属性。 在 Build Events 中,在 Pre-build event command line 下,添加这两行代码:
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
关于c# - 无法将文件从 obj\Debug 复制到 bin\Debug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2625239/