views:

192

answers:

3

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?

Thanks.

A: 

Take a look at the output and DCU directories of the project. You're probably picking up an old DCU from a shared DCU directory. Clear out the DCUs and re-build.

Chris Thornton
+1  A: 

I have run into that too, and now I tend to give files unique names, like instead of Main.pas, it might be ProjectNameMain.pas

Check your Library paths and Browsing paths in the Environment Options

jasonpenny
If you use this project as the starting point for a new (or parallel) project, all files need renaming :P - Imagine how it would be to have SysUtils50, SysUtils60, SysUtils70 and so on in the RTL, and with every new Delphi version developers need to fix all references to RTL unit names :)
mjustin
+4  A: 

Do you use relative paths?

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 your working dir. 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.

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.

Marco van de Voort
i believe this is absolutely correct. now when i open an unrelated file, i never use File, Open...i drag the file from explorer to delphi or let explorer decide how to open the file.
X-Ray
+1. I discovered the File->Open trick in my D2006 days and got used to it. I have nevered bothered to check if it is still necessary in D2007.
Ulrich Gerhardt
I still need it in D2009
Marco van de Voort