Delphi 调试一个错误的单元 [英] Delphi debug a wrong unit

查看:22
本文介绍了Delphi 调试一个错误的单元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 D2006 的一个奇怪行为,因为它有时会发生.我有一个要调试的项目.我要调试的文件名为Main.pas".我有另一个具有相同单元名称的不相关项目,有时调试会提示我错误的主文件而不是当前项目中的主单元.这发生在我身上,有其他同名文件.我无法调试,因为调试键不起作用(它们什么也不做).你遇到过同样的问题吗?我该如何解决?

This is an odd behaviour by my D2006 as it happens sometimes only. I have a project I want to debug. The file I want to debug is named 'Main.pas'. I have another unrelated project with the same Unit name and sometimes the Debug prompt me the wrong Main file instead of the Main unit from the current project. This have happened to me with other files with the same name. I can't debug then as the debug keys don't work (they just don't do anything). Do you have experienced the same problem? How can I fix it?

谢谢.

推荐答案

你使用相对路径吗?

如果是,我发现将工作目录设置为我的项目目录 y 使用 File->Open 从我的项目目录加载文件会有所帮助.导航和加载明显地设置了工作目录,修复了您认为正在使用相对于项目的路径的情况,但 delphi 相对于 IDE 的工作目录来解释它们.不过,请先关闭所有其他选项卡,以免出错.由于 delphi 编译器是一个 dll,它与 IDE 进行深度交互,并且可能有权访问打开的文件.(它可以编译未保存的文件!)

If yes, I found out it helps to set the working directory to my projects directory y loading a file from my projects dir using File->Open. The navigating and loading apparantly sets the working dir, fixing the case where you THINK you are using paths relative to your project, but delphi interprets them relative to the working dir of the IDE. Close all other tabs first though, to avoid mistakes. Since the delphi compiler is a dll, it interacts deeply with the IDE, and probably has access to which files are opened. (it can compile unsaved files!)

如果不是,它可能是一个怪异的事件,但仍然具有相同的起源.养成先关闭其他文件的习惯(右键单击选项卡 -> 关闭所有其他文件),然后固定工作目录(通过文件打开解决方法使用加载单元)可能会有所帮助.

If not, it might a freak occurance, but still have the same origin. Developing a habit to first close other files (right click on tab->close all other), and fixate the working dir (with the load unit via file-Open workaround) might help.

我感觉BDS系列IDE似乎比经典IDE更受这个问题的影响,但是经典的问题也存在.可能就像在 BDS 中使用更多花哨的 opendialog 选项一样简单,增加工作目录更改的机会.

I've the feeling the BDS series of IDEs seem to suffer from this more than the classic ones, but the problem existed in the classic ones too. Could be as simple as using more fancy opendialog options in BDS, increasing the chance on working dir change.

更新 此外,只有在没有其他项目打开时才打开项目有帮助.因此,在打开新项目之前始终单击旧项目,如果 IDE 已打开并加载了另一个项目,则不要在 Windows 资源管理器中单击项目.

update Also only opening projects when no other projects are open helps. So always click the old project before opening the new, and don't click a project in the windows explorer if the IDE is open with another project loaded.

Delphi XE 仍然受此困扰

Delphi XE still suffers from this

这篇关于Delphi 调试一个错误的单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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