Sudden Error opening Forms in the IDE in Delphi 6 - List Index out of bounds 0)

I am having an error when opening \ closing forms in the IDE.  I get a "List index out of bounds (0)" error.  The other developer here is getting the same error.  The error is occuring on some of the forms in our application, but not on all forms.  

The error occurs at run-time as well.  I am not sure how to track down the problem, Any Advice?

Who is Participating?
2266180Connect With a Mentor Commented:
I sugest installing madexcept or eurekalog both of which will give you the stack trace of the error and thus telling you where the problem is iwthout wasting further time ;)
My humble guess is that some components (usually 3rd party components) are doing this. I would debug by removing any funny components until you no longer see the error.
As another idea, make sure you have the latest version of your Delphi
foremostcoAuthor Commented:
We are still maintaining an old version of our system while developing a completely new version.  We have't added or changed any components or code that should have caused this problem, and the forms that are crashing suddenly started crashing on both development machines.  

And ideas on how to find where the error occurs within the form being opened.  It happens in the IDE, and in the running application.  The application does compile.
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

So what's changed?
Are you saying 6 months ago you loaded this program into the IDE and everything was fine for all developers?
Now 6 months later you load the project for the first time - same systems with the same versions of delphi - and you get an error? see either it's a Delphi bug and you should just change versions or update delphi,
or it's a problem with a component and you need to remove and check the components.
foremostcoAuthor Commented:
It worked fine on Friday.  This weekend, we updated our SQL server from 2000 to 2005, but this problem occurs even if we are pointed to our old server.  
Yeah could have been a bad save by somebody.
I've had 1 bad experience with a component that messed up my form. I think the Dice component in JVCL - I was just trying to see what it did - and that would lock up the whole IDE and I couldn't use the form. I don't exactly recall how I solved the problem but I think I had to go and edit the dfm and the unit and try remove the component from there - but I'm not sure how I did it.
Maybe try load any backups you may have.
Also in my IDE there's this drop-down list that saves the layout of the IDE - sometimes I reset this to "Classic Undocked" - not much help I know but it's worth a shot - resetting the layout of the IDE.
What if for example your DFM said a certain component should be on your form and the itemindex should be '5' but the component only has 4 items?
What if somehow your project has confused your unit and your dfm?
In this case it would be the IDE's fault not the component's and your only solution is to fix it within the project itself - changing delphi versions or upgrading probably wouldn't help.
So my guess is something got corrupted somewhere.
foremostcoAuthor Commented:
I have tried deleting the layout files.  This does let me open the file in the IDE, but any change I attempt, or even closing it gives the same error.  

I am actually seeing the error in the version of my system that was released back in April, and worked until we changed the database.  It also gives me the error against the new live (SQL 2005) and old (SQL 2000) server.
...i wish i knew how to read stack traces and things. I find, if it doesn't take me to the line of source code with the problem, it's pretty much no help at all.
tobjectpascalConnect With a Mentor Commented:
Delphi on an exception will give you a line it errors from however sometimes the problem is further back than that.. When an exception takes place do this

Delphi > View > Debug Windows > Call Stack
Alt Ctrl and S

At the bottom of the call stack window is the start of the stack, everytime your program goes somewhere, does something, the function/procedure name gets put in, so all you do is work your way from the top (where the error is) down until you find the component/code at fault

Attached an image showing an example, notice how each procedure that gets called gets thrown onto the stack, well everytime you do a Call, the pointer of execution (EIP) gets thrown onto the stack, the esp/ebp gets updated and on Ret back it pops the value back onto EIP so essentially that's what's taking place and Delphi just takes a note on where it was at the time, all quite clever stuff..

Geert GOracle dbaCommented:
delete the .dsk file in the .dpr directory helps ?
That's great and I'm sure I've read up on this all before - however for example just now it only says "Process is not accessible" is the only item in the call stack ...
That's why I always just resort to the good 'ol fashioned
x 10,000 times
MerijnBSr. Software EngineerCommented:
you can post a madexcept or eurekalog call stack here and we might be able to help you with it.
rfwoolf: just try using one of the products mentioned above: they giuve proepr stacktrace with source file and line number (where applicable). and in case the error is in teh delphi sources and you really want to see what's there because you just can't figure out why the error is happening, you just recompile with debug dcus and you'll get line numbers for those files as well ;)
here are 2 samples from 2 bugreports generated by madexcept that I found on my hdd. I trust it's easy to read and understand :)
with debug dcus:
exception number  : 1
exception class   : EVariantInvalidArgError
exception message : Invalid argument.
main thread ($50c):
0045bafc +07c aa.exe Variants   609 +10 HandleConversionException
0045ce28 +430 aa.exe Variants  1349 +75 @VarToInteger
005332bc +114 aa.exe Client     129  +9 TClient.Create
00530fb6 +06e aa.exe Unit1      193  +5 TClientForm.FormCreate
004d2bcd +031 aa.exe Forms     2648  +3 TCustomForm.DoCreate
004d283d +019 aa.exe Forms     2575  +1 TCustomForm.AfterConstruction
00403dcb +007 aa.exe System    9074  +1 @AfterConstruction
004d280a +176 aa.exe Forms     2569 +16 TCustomForm.Create
004dbaa0 +03c aa.exe Forms     6946  +4 TApplication.CreateForm
00539ef7 +02f aa.exe theClient   46  +2 initialization
without debug dcus:
exception number  : 1
exception class   : EVariantTypeCastError
exception message : Could not convert variant of type (Null) into type (String).
main thread ($bc0):
004575a3 +06f Project1.exe Variants       VarCastError
0045b302 +0aa Project1.exe Variants       @VarToLStr
004a1c95 +095 Project1.exe Unit1    81 +1 TForm1.ItemClick
00490d4a +0a6 Project1.exe Menus          TMenuItem.Click
00491f2b +02b Project1.exe Menus          TMenu.DispatchPopup
00492c0b +0b7 Project1.exe Menus          TPopupList.WndProc
00492b25 +01d Project1.exe Menus          TPopupList.MainWndProc
004680c8 +014 Project1.exe Classes        StdWndProc
77fb4da3 +010 ntdll.dll                   KiUserCallbackDispatcher
77d74e99 +00a user32.dll                  TrackPopupMenuEx
77d8dffa +014 user32.dll                  TrackPopupMenu
004932e4 +0a8 Project1.exe Menus          TPopupMenu.Popup
0048146a +106 Project1.exe Controls       TControl.WMContextMenu
0048680f +05f Project1.exe Controls       TWinControl.WMContextMenu
004803f4 +188 Project1.exe Controls       TControl.WndProc
0048333f +157 Project1.exe Controls       TWinControl.WndProc
00498185 +421 Project1.exe Forms          TCustomForm.WndProc
00482fbc +02c Project1.exe Controls       TWinControl.MainWndProc
004680c8 +014 Project1.exe Classes        StdWndProc
77d45ca3 +04e user32.dll                  DefWindowProcA
77d45f82 +014 user32.dll                  CallWindowProcA
00483423 +0d7 Project1.exe Controls       TWinControl.DefaultHandler
00499602 +05a Project1.exe Forms          TCustomForm.DefaultHandler
00480a08 +00c Project1.exe Controls       TControl.WMRButtonUp
004803f4 +188 Project1.exe Controls       TControl.WndProc
00483271 +089 Project1.exe Controls       TWinControl.WndProc
00498185 +421 Project1.exe Forms          TCustomForm.WndProc
00482fbc +02c Project1.exe Controls       TWinControl.MainWndProc
004680c8 +014 Project1.exe Classes        StdWndProc
77d44387 +006 user32.dll                  DispatchMessageA
0049e49b +083 Project1.exe Forms          TApplication.ProcessMessage
0049e4ba +00a Project1.exe Forms          TApplication.HandleMessage
0049e6da +096 Project1.exe Forms          TApplication.Run
004a22b3 +03b Project1.exe Project1 18 +3 initialization

Open in new window

Thanks for the help on debugging guys, sorry to foremostco for slightly hijacking your thread - at least you know people are reading it and this is quite enlightening :)

I am learning something new every several days :)
foremostcoAuthor Commented:
We had some code that was referencing a file on our network.  It was reading this file and then using it to reference a list.  The file was removed and this caused a problem.  They was we solved it was to remove the component, and then dynamically create it in our application.  When we were at run-time, we were able to trace into the component's code and find the problem.
madexcept would show the stacktrace of an exception from:
- the IDE (everything not related to your project)
- runing the applicaiton from the IDE
- running the application outside the IDE

I never used eurekalog so I cannot say if it does all the above, but using madexcept, as I suggested, would have given you the stacktrace of the exception and thus allowing you to fix the problem.

so I do not agree with closing withouat accepting one or more of the experts comments.
I recommend split:
ciuly {http:21746855} & tobjectpascal {http:21748549}
hm... the old way of giving short links seems to be changed. the IDs are 21746855 and 21748549
right :D

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.