构建错误:“该进程无法访问该文件,因为它正被另一个进程使用" [英] Build error: "The process cannot access the file because it is being used by another process"

查看:32
本文介绍了构建错误:“该进程无法访问该文件,因为它正被另一个进程使用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 C# webforms 应用程序,直到今天它一直运行良好.

I've got a C# webforms app, that until today had been working just swimmingly.

现在,突然间,每次我尝试运行该应用程序时,都会出现文件锁定错误:

Now today, all of a sudden, every time I try run the app, I get a file locking error:

无法将文件objDebugMyProject.exe"复制到binDebugMyProject.exe".该进程无法访问文件binDebugMyProject.exe",因为它正被另一个进程使用.

Unable to copy file "objDebugMyProject.exe" to "binDebugMyProject.exe". The process cannot access the file "binDebugMyProject.exe" because it is being used by another process.

谷歌搜索错误并没有发现任何明显的错误,即 VS 认为文件已锁定.并且肯定 Visual Studio 本身会锁定文件,因为当我关闭 VS 并重新打开它时,项目执行得很好 - 第一次.当我尝试第二次运行它时,出现文件锁定错误.

Googling the error doesn't come up with anything beyond the obvious, i.e. VS thinks the file is locked. And it is definitely Visual Studio itself that locks the file, because when I close VS and reopen it, the project executes fine - the first time. When I try to run it a second time, I get the file locking error.

每次我想运行应用程序时都关闭 VS 并重新打开不是可行的解决方法!如何找出锁定文件的原因,并阻止它被锁定?

Closing VS and reopening every time I want to run the app is not a viable workaround! How do I find out what's locking the file, and stop it from getting locked?

另一个有趣的发现:我什至不必运行该应用程序.只编译一次就会导致文件锁定;我不能连续编译两次!

Another interesting discovery: I don't even have to run the app. Just compiling it once causes the file locking; I cannot compile twice in a row!

此问题特定于我的解决方案中的一个项目.所有其他项目都运行良好,可以根据需要执行多次.只有这个项目自己被锁定了.

This problem is specific to one project in my solution. All other projects work fine and can be executed as many times as I like. It's only this one project that gets itself locked up.

推荐答案

我找到了一个对我有用的简单解决方案.它是这样的:

I have found a simple solution which works for me. It goes like this:

出现问题时,只需将顶部的构建配置更改(如果在Release"为Debug",反之亦然),构建然后改回之前的配置并再次构建.

When the problem occurs, just change the building configuration at the top (if in "Release" to "Debug" and vice versa), build and then change back to previous configuration and build again.

我想更改配置会释放 vcshost 和 devenv.

I suppose that changing the configuration releases the vcshost and devenv.

这篇关于构建错误:“该进程无法访问该文件,因为它正被另一个进程使用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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