无法在 Visual Studio 中调试,因为进程无法访问文件

Unable to debug in Visual Studio because process can not access file

当我尝试在 Visual Studio 中调试时,我收到错误消息:

Unable to copy file "C:\Users\Name\Dropbox\Company Name\Development\Product Name 4 - Release Candidate\packages\MahApps.Metro.1.1.2.0\lib\net45\MahApps.Metro.dll" to "bin\Debug\MahApps.Metro.dll". The process cannot access the file 'bin\Debug\MahApps.Metro.dll' because it is being used by another process. Product Name 4 - Release Candidate

我该如何解决这个错误?

这种情况在 Dropbox 中经常发生。 Dropbox 在为文件编制索引时偶尔(非常短暂)锁定文件,如果您碰巧试图打开同时设置了写入属性的文件句柄,程序将收到文件 I/O 异常(这也可能发生在您自己的代码中,因此如果您经常使用 Dropbox,请务必优雅地处理它)。

再试 compiling/running 看看问题是否消失。如果没有,那么您的应用程序实例 运行 可能仍在后台。如果您的程序分叉,就会发生这种情况。 VS 将终止原始进程,但通常不会从中分叉进程。检查任务管理器以确保。它将在 Windows 8/8.1

中列为后台进程