建立在Visual Studio 2010时,锁定的文件 [英] Locking files when building in Visual Studio 2010

查看:193
本文介绍了建立在Visual Studio 2010时,锁定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,#1。

近日,当我已经在Visual Studio 2010编程,我已经得到了问题与试图建立,给我下面的错误试图建立项目10次后,当VS锁定斌/调试/(项目名).exe文件:

Recently, when I've been programming in Visual Studio 2010, I've been getting the problem with VS locking the bin/Debug/(ProjectName).exe file when trying to build and gives me the error below after trying to build the project 10 times:

无法复制文件obj\x86\Debug\TileEngine.exe到bin\x86\Debug\TileEngine.exe。原因是其正在使用由另一个进程的进程无法访问该文件'bin\x86\Debug\TileEngine.exe。

Unable to copy file "obj\x86\Debug\TileEngine.exe" to "bin\x86\Debug\TileEngine.exe". The process cannot access the file 'bin\x86\Debug\TileEngine.exe' becuase it is being used by another process.

当我编辑源代码,然后尝试调试出现问题。
我已经用不同的托运程序,并使用文件的唯一程序的Visual Studio。

The problem appears when I edit the source and then try to Debug. I've checked using different programs, and the only program using the file is Visual Studio.

如果我等待约10分钟试图建立之前,它似乎正常工作,但尝试不同的东西的时候,这是不好的需要尝试一些之前要等待10分钟。

If I wait for about 10 minutes before trying to build, it seems to work properly, but when trying different things, it isn't good needing to wait 10 minutes before trying something.

我都试过这个不同的解决方案现场还有我到处都可以找到谷歌。

I've tried different solutions both on this site as well as everywhere I can find on Google.

在这里#2一些不同的问题,我发现一个解决办法是,你进入项目性状>生成事件,然后在预生成事件命令行的补充:

In some different questions here on Stackoverflow, I've found one solution being that you go into Project Properties > Build Events and then in the Pre-build event command line add:

if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

这使人们有可能为我打造的项目更多的时间比我平时可以,但是当再次编辑代码,然后打造,同样的错误出现。

This made it possible for me to build the project one more time than I usually could, but when editing the code again, and then building, the same error appeared.

注意:试图建立一个版本,而不是调试建设似乎打破预生成脚本,并将其与代码1,这似乎使VS无法正常建立退出。取出预生成脚本,使它像正常了,仍然出现同样的错误,虽然工作

Note: Trying to build a release instead of a debug build seems to break the pre-build script and it exits with the code '1', which seems to make VS unable to build properly. Removing the pre-build script makes it work like "normal" again, still with the same error though.

这是另一种解决办法,我发现,但还没有工作无论是对我,所以我假设的Visual Studio已经有了所有必需的,以管理员身份运行实际上并不权限。任何区别

This is another solution I've found, but havent worked either for me, so I assume that Visual Studio already have all the permissions required and running as Administrator doesn't actually make any difference.

在这个问题的 Visual Studio中构建失败:无法复制从obj\debug EXE文件到bin\debug ,我发现了另一种解决方案,其中包括修改的AssemblyVersion 属性\AssemblyInfo.cs 文件,为2.0.0.0
然而,这并没有为我做任何任何区别

In this question, Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug, I found another solution that included changing the AssemblyVersion, in the Properties\AssemblyInfo.cs file, to "2.0.0.0". This, however, haven't made any difference whatsoever for me.

据在这里和那里在互联网上的一些不同的答案时,Visual Studio显然使用内置项目的可执行文件来渲染用户控件设计师(?)。于我而言,这可能不是它,虽然,因为我使用XNA主要是,它不使用用户控件设计师。

According to some different answers here and there on the Internet, Visual Studio apparently uses the built project executable to render the UserControl designer(?). In my case, this is probably not it, though, since I use XNA mostly and it doesn't use the UserControl designer.

这可能是我没能正确地实现解决方案。我只是在想,虽然,那如果这是解决方案,我怎么也没有被要求做之前就来了。我认为XNA卸载,获取通过内容管道加载的一切,因此该方案不会作出任何实际意义。

This might be a solution that I have failed to implement properly. I'm just thinking though, that if this is the solution, how come I haven't been required to do it before. I assume XNA unloads everything that gets loaded through the Content pipeline, therefore this solution wouldn't' make any real sense.

如果有任何人能够传播在这个问题上的一些光,这将是真正真棒,因为它是从真正的编程什么阻止我,因为我不喜欢等待了10分钟,因为我做了一个2秒改变这一切的时候。

If there is anyone that is able to spread some light on this issue, it would be really awesome, as it is stopping me from programming anything really, because I don't like waiting for 10 minutes because I've made a 2 second change all the time.

推荐答案

我碰到这个问题了几次自己。

I've run into this problem a few times myself.

矿可能不是来自同一个原因是你的,但我会告诉你什么地方我错了,我怎么固定它,希望它会帮助你。

Mine might not be from the same cause as yours, but I'll tell you what went wrong with me and how I fixed it, hopefully it'll be helpful to you.

基本上,我的计划从来没有完全正确退出,即使它出现了。它将继续运行,从而继续锁定该文件。

Basically, my program never fully exited properly, even when it appeared to. It would continue to run, and thus continue to lock down the file.

一个快速肮脏的修复我最初使用(和方式来证明,如果是这种情况)是

A quick dirty fix I used initially (and a way to prove if this is the case) is:


  • 开启任务管理器(按Ctrl-Alt-Del组合)

  • 单击进程标签

  • 查找你的程序的名称(TileEngine.exe)

  • 注:有可能会被name_vshost.exe(TileEngine_vshost.exe)这是一个VisualStudio的事情,忽略,这是不相关的。

  • 如果你找到它,就意味着你的程序还没有实际的完全退出。

  • 如果它的存在,一下就可以了按结束进程

  • Open Task Manager (Ctrl-Alt-Del)
  • Click Processes tab
  • Look for your program's name (TileEngine.exe)
  • Note: There will probably be name_vshost.exe (TileEngine_vshost.exe) That's a VisualStudio thing, ignore that, it's not relevant.
  • If you find it, it means your program hasn't actual exited fully.
  • If it's there, click on it and press "End Process"

所以,如果它的存在,然后出于某种原因,你的程序没有关闭,像我这样做

So if it's there, then for some reason, your program didn't shut down, like mine did.

通常,这被推出和被遗忘的一个线程,或者说永远不会完成一个异步任务,或者类似的东西。

Often, this is from a thread being launched and forgotten, or an Async task that never completes, or something like that.

请确保您OnExiting(..)你杀死所有正在运行的线程void函数。

Make sure in your OnExiting(..) void function that you kill all running threads.

如果你的程序仍在尽管收尽了最大努力跑所有线程和其他受体阻滞剂,可以使用非常脏的坏方法:
在OnExiting(...)运行代码。System.Diagnostics.Process.GetCurrentProcess()杀死(); - 这将TASKMANAGER式FORCESHUTDOWN当前进程......这仅仅是作为应急I-不可阻挡的化妆它工作-任意其它路法

If your program is still running despite best attempts to close all threads and other blockers, you can use the very dirty bad method: In OnExiting(...) run the code "System.Diagnostics.Process.GetCurrentProcess().Kill();" - this will taskmanager-style forceshutdown the current process... this is only as an emergency I-can't-make-it-work-any-other-way method.

这篇关于建立在Visual Studio 2010时,锁定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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