错误:无法访问文件bin / Debug / ...因为正在被其他进程使用 [英] Error: Cannot access file bin/Debug/... because it is being used by another process

查看:160
本文介绍了错误:无法访问文件bin / Debug / ...因为正在被其他进程使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我调试我的项目时,我收到以下错误:

When I debug my project, I get following error:


无法复制文件obj\Debug\My Dream .exe到bin \Debug\My Dream.exe,进程无法访问文件bin \Debug\My Dream.exe,因为它被另一个进程使用。

"Unable to copy file "obj\Debug\My Dream.exe" to "bin\Debug\My Dream.exe". The process cannot access the file 'bin\Debug\My Dream.exe' because it is being used by another process."

使用Process Explorer,我看到MyApplication.exe已经出来,但是系统进程仍然使用它,尽管我以前停止了调试。
每当我更改代码并开始调试它将会发生。如果我将项目复制到USB并进行调试,则运行正常。

Using Process Explorer, I see that MyApplication.exe was out but System process still uses it although I stopped debug before. Whenever I change my code and start debug it is going to happen. If I copy project to USB and debug, it runs OK.

为什么?我如何解决这个错误?

Why? How can I fix this error?

我使用Window 7 Professional。使用Xp我从来没有这个错误。

I use Window 7 Professional. With Xp I have never got this error.

推荐答案

呃,这是一个老问题,仍然在Visual Studio中弹出偶尔。它咬了我几次,我失去了几个小时重新启动并与VS战斗。我确信这里已经在这里讨论过了不止一次。在MSDN论坛上也有人讨论过。没有一个实际的解决方案,但有几个解决方法。 开始研究这里

Ugh, this is an old problem, something that still pops up in Visual Studio once in a while. It's bitten me a couple of times and I've lost hours restarting and fighting with VS. I'm sure it's been discussed here on SO more than once. It's also been talked about on the MSDN forums. There isn't an actual solution, but there are a couple of workarounds. Start researching here.

发生的情况是,VS正在获取文件上的锁定,然后不释放。讽刺的是,该锁阻止VS本身删除文件,以便在重建应用程序时可以重新创建该文件。唯一明显的解决方案是关闭并重新启动VS,以便它释放文件上的锁定。

What's happening is that VS is acquiring a lock on a file and then not releasing it. Ironically, that lock prevents VS itself from deleting the file so that it can recreate it when you rebuild the application. The only apparent solution is to close and restart VS so that it will release the lock on the file.

我的原始解决方法是打开bin / Debug文件夹并重命名可执行文件。如果它被锁定,您不能删除,但您可以重命名它。所以你可以添加一个数字到最后或某些东西,这允许你继续工作,而不必关闭所有的窗口,并等待VS重新启动。 有些人甚至使用预构建事件进行自动化,以将随机字符串附加到旧输出文件名的末尾。是的,这是一个巨人黑客,但是这个问题让我感到沮丧和虚弱,你会做任何事情。

My original workaround was opening up the bin/Debug folder and renaming the executable. You can't delete it if it's locked, but you can rename it. So you can just add a number to the end or something, which allows you to keep working without having to close all of your windows and wait for VS to restart. Some people have even automated this using a pre-build event to append a random string to the end of the old output filename. Yes, this is a giant hack, but this problem gets so frustrating and debilitating that you'll do anything.

经过一番更多的实验,这个问题似乎只有当您与其中一位设计师开放的项目建立时才会出现。所以,长期为我工作的解决方案,阻止我再次处理这些愚蠢的错误之一是确保在构建WinForms项目之前,我总是关闭所有的设计器窗口。是的,这也有点不方便,但是它肯定会让裤子不得不重新启动VS两次或更多的时间。

I've later learned, after a bit more experimentation, that the problem seems to only crop up when you build the project with one of the designers open. So, the solution that has worked for me long term and prevented me from ever dealing with one of those silly errors again is making sure that I always close all designer windows before building a WinForms project. Yes, this too is somewhat inconvenient, but it sure beats the pants off having to restart VS twice an hour or more.

我认为这也适用于WPF,虽然我不使用它,并没有亲自体验过这个问题。

I assume this applies to WPF, too, although I don't use it and haven't personally experienced the problem there.

我还没有尝试在VS 2012 RC上重现它。我不知道它是否在那里修复。但是,到目前为止,我的经验是,即使微软声称已经修复,仍然会弹出窗口。它仍然在VS 2010 SP1。我不是说他们的程序员是白痴,他们当然不知道他们在做什么。我认为,只有多种原因导致错误和/或在实验室中难以可靠地再现。这是我没有亲自提交任何错误报告的原因(尽管我已经+1了其他人民),因为我似乎无法可靠地复制它,而是像可恶的雪人。

I also haven't yet tried reproducing it on VS 2012 RC. I don't know if it's been fixed there yet or not. But my experience so far has been that it still manages to pop up even after Microsoft has claimed to have fixed it. It's still there in VS 2010 SP1. I'm not saying their programmers are idiots who don't know what they're doing, of course. I figure there are just multiple causes for the bug and/or that it's very difficult to reproduce reliably in a laboratory. That's the same reason I haven't personally filed any bug reports on it (although I've +1'ed other peoples), because I can't seem to reliably reproduce it, rather like the Abominable Snowman.

< end rant,特别是没有人>

这篇关于错误:无法访问文件bin / Debug / ...因为正在被其他进程使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆