C# 创建调试信息时出错 - 代码无法编译
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1477582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error Creating Debug Information - Code Won't Compile
提问by modernzombie
I'm using VS 2008. When ever I make a change in my code and try to compile I get the following error:
我正在使用 VS 2008。每当我对代码进行更改并尝试编译时,都会出现以下错误:
Error 7 Unexpected error creating debug information file 'C:\Documents and Settings\jbezanson\My Documents\MyProjects\DispatchBoard\DispatchBoard\obj\Debug\DispatchBoard.PDB' -- 'C:\Documents and Settings\jbezanson\My Documents\MyProjects\DispatchBoard\DispatchBoard\obj\Debug\DispatchBoard.pdb: The process cannot access the file because it is being used by another process. ' DispatchBoard
错误 7 意外错误创建调试信息文件 'C:\Documents and Settings\jbezanson\My Documents\MyProjects\DispatchBoard\DispatchBoard\obj\Debug\DispatchBoard.PDB' -- 'C:\Documents and Settings\jbezanson\My Documents\ MyProjects\DispatchBoard\DispatchBoard\obj\Debug\DispatchBoard.pdb:进程无法访问该文件,因为它正被另一个进程使用。' 调度台
Using Process Explorer, it is always devenv.exe
that is locking the file. If I run in Release mode this does not happen. It started 2 days ago when I started a WPF application, and since then it happens with every application I work on.
使用进程资源管理器,总是devenv.exe
锁定文件。如果我在发布模式下运行,这不会发生。它开始于 2 天前,当我启动一个 WPF 应用程序时,从那时起它发生在我工作的每个应用程序中。
The only info I could find from Google was referring to a bug in VS 2003.
我能从 Google 找到的唯一信息是指 VS 2003 中的一个错误。
Anyone else have this problem? How do I fix it? It is getting very annoying having to kill the file handle every time I want to compile.
还有其他人有这个问题吗?我如何解决它?每次我想编译时都必须杀死文件句柄,这变得非常烦人。
采纳答案by Jodi
回答by manji
Have you tried closing VS, deleting obj folder
then restarting VS?
您是否尝试过关闭 VS,删除obj folder
然后重新启动 VS?
回答by AndersK
Since you say you have it on all applications you work on it sounds like a more global problem. You could try and reinit the vs2008 by writing
既然你说你在你处理的所有应用程序上都有它,这听起来像是一个更普遍的问题。您可以尝试通过编写重新启动 vs2008
devenv.exe /setup
devenv.exe /setup
Edit: link to command line options
编辑:链接到命令行选项
回答by erikkallen
I have solved a similar problem by adding these lines as a pre-build event:
我通过将这些行添加为预构建事件解决了类似的问题:
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" move "$(TargetPath)" "$(TargetPath).locked"
With proper modifications, it might help your problem.
通过适当的修改,它可能会帮助您解决问题。
回答by Alex Wolf
I just came across the same problem today. And then I realized what went wrong: I had couple of Visual Studio windows opened at the same time, and one of them was in debug mode.
我今天刚遇到同样的问题。然后我意识到出了什么问题:我同时打开了几个 Visual Studio 窗口,其中一个处于调试模式。
When I stopped debug mode in that one, the problem was solved.
当我在那个模式中停止调试模式时,问题就解决了。
That happens when you have a "fistfull of VS windows" opened.
当您打开“一大堆 VS 窗口”时会发生这种情况。
回答by Alex Clark
I had the same problem this morning and noticed that I had another project open that had a reference to the one that would not compile or debug. I removed the reference (as I didn't actually need it) and it was fine.
今天早上我遇到了同样的问题,并注意到我打开了另一个项目,该项目引用了无法编译或调试的项目。我删除了引用(因为我实际上并不需要它)并且很好。
回答by Abbas
If you have multiple instances of VS open, close other instances (apart from the one you are trying to compile) - this may resolve the issue.
如果您打开了多个 VS 实例,请关闭其他实例(除了您尝试编译的实例)- 这可能会解决问题。
回答by Mike Anderson
I had this issue today. In my case, I had just grabbed the data from my company's source control and instantly hit this issue when I tried to compile the project. The issue ended up being that the \bin folder was set to Read Only. To solve the issue, I just made the folder not Read Only.
我今天遇到了这个问题。就我而言,我刚刚从我公司的源代码管理中获取了数据,并在尝试编译项目时立即遇到了这个问题。问题最终是 \bin 文件夹被设置为只读。为了解决这个问题,我只是让文件夹不是只读的。
回答by giraffe
I changed the 'StartUp Project' of my solution to a project without reference to the locked file's project. This solved the issue for me using VS 2010 SP1.
我将解决方案的“启动项目”更改为一个项目,而不参考锁定文件的项目。这为我使用 VS 2010 SP1 解决了这个问题。
(Process Explorer said msvsmon.exe (started by devenv.exe) locked the pdb file. After changing the startup project the processes msvsmon.exe and .vshost.exe disappeared and so did the file handle.)
(进程资源管理器说 msvsmon.exe(由 devenv.exe 启动)锁定了 pdb 文件。更改启动项目后,进程 msvsmon.exe 和 .vshost.exe 消失了,文件句柄也消失了。)
Alex Clark, thank you for pointing me in the right direction.
亚历克斯克拉克,谢谢你为我指明了正确的方向。
回答by Kelvin
This worked for me. What I done was that close my visual studio and delete the .suo file and then re-open the solution. The locking should be disappeared now. Cheers.
这对我有用。我所做的是关闭我的视觉工作室并删除 .suo 文件,然后重新打开解决方案。锁定现在应该消失了。干杯。