Unhandled OutOfBoundsException

I am working on a web app and have encountered an error that only happens when the app is run from the web server.

Unhandled OutOfBoundsException


The error does not occur when running in the IDE. The app uses a container control with control sets and the message appears when you scroll the container control. No other information is displayed that gives me any clue what is causing the error. I suspect it may have something to do with control indexes not behaving the same way on the web server as they do in the ID but that is jus a guess at this point. Anybody have any sage wisdom on how to go about tracking down the culprit?

One more bit of info. The app also has a listbox in it that also causes the same error when you click on a cell. If I remove all the code in CellClick the error doesn’t occur but with the following minimal amount of code, (only part of what is supposed to be there), a CellClick will cause the Unhandled OutOfBoundsException:

[code]CellClick(Row As Integer, Column As Integer)
Dim i As Integer
Dim b As Boolean
Dim p As WebPicture

b = Session.JobSelected(Row)

[code]Sub JobSelcted(CurrentJobID As Integer)
Session.dbJobID = Session.JobData(CurrentJobID,0)
Session.dbJobName = Session.JobData(CurrentJobID,1)
Session.dbJobYearID = Session.JobData(CurrentJobID,3)
Session.dbJobCustomerName = Session.JobData(CurrentJobID,4)
Session.dbJobTrimSize = Session.JobData(CurrentJobID,5)
Session.dbJobBindingStyle = Session.JobData(CurrentJobID,6)
Session.dbJobDeliveryCode = Session.JobData(CurrentJobID,7)
Session.dbJobNumCopies = Session.JobData(CurrentJobID,8)
Session.dbJobShipDate = Session.JobData(CurrentJobID,9)

WebPage1.JobInfoCC.Label_dbJobName.Text = “Job Name: " + Session.dbJobName
WebPage1.JobInfoCC.Label_dbJobNumber.Text = “Job Number: " + NthField(Session.dbJobName,”-”,1)
WebPage1.JobInfoCC.Label_dbJobYear.Text = "Job Year: " + Session.dbJobYearID
WebPage1.JobInfoCC.Label_dbJobCustomerName.Text = "Customer Name: " + Session.dbJobCustomerName
WebPage1.JobInfoCC.Label_dbJobTrimSize.Text = " Trim Size: " + Str(Session.dbJobTrimSize)
WebPage1.JobInfoCC.Label_dbJobBindingStyle.Text = "Binding Style: " + Session.dbJobBindingStyle

Return True

I can only assume that the JobData Array is somehow causing the Unhandled OutOfBoundsException but this makes no sense to me since the opening code for the app works using the same array without any modifications.

How about using a msgbox just before using that array and display the ubound just to be sure that it’s actually being set.

Well, that’s interesting. I replaced all the code in CellClick with:

CellClick(Row As Integer, Column As Integer)
MsgBox "Row " + Str(Row) + EndOfLine + "UBound(JobData,1) " + Str(UBound(Session.JobData,1))

AND… I still get the Unhandled OutOfBoundsException.

So next I changed the code to:

CellClick(Row As Integer, Column As Integer)
MsgBox "Row " + Str(Row)

AND… I still get the Unhandled OutOfBoundsException. So, is the problem with the data in the ListBox? I’m clicking on cell one or 2 out of over 4k cells.

[quote=134001:@Tom Dixon]CellClick(Row As Integer, Column As Integer)
MsgBox "Row " + Str(Row)[/quote]

If there is nothing else in CellClick, integers normally cannot trigger any OutOfBoundsException …

And when you remove the MsgBox, the error goes away, right ?

Correct. As long as there is no code in CellClick nothing happens.

What I am puzzled about is that the MsgBox cannot do a OutOfBoundsException. Is that all you got there ?

To get such an error requires an array or a control that has a bound.

I’m tired but there is a typo

Sub JobSelcted

Shouldn’t it be

Sub JobSelected

Are you doing much, if any, processing within the “Open” event of the webpage or any of its controls?

Michael I’m as puzzled as you are. That shouldn’t happen with just a MsgBox.

nige. Correct. That is a typo done here.

Randy I was doing a bunch as methods within a container control but I’m in the process of moving all that code to the session just in case. I haven’t finished that and put a build on the web server but hope to do that by morning to test if the problem autmagically goes away.

Initializing visual controls in the “Open” event can be problematic. Unless absolutely necessary, I would suggest moving the code in the “Open” events to the “Shown” events (and see if you still get your OutOfBounds Exception). My guess, and it is purely a guess, is that an event is getting processed before an actual selection is made in the ListBox. This means that the ListBox’s ListIndex is “-1” – which of course would be out of bounds if you were using it to reference an array of some sort.

Of course I have no idea because we all are working blind without seeing your code.


If anything as simple as a Msgbox triggers an exception completely unrelated to the kind of variable used it looks terribly much like a bug deep into Xojo. Have you tried something as innocent as

row = row+1 or system.debuglog "Row " + Str(Row)
If any one of these two lines by itself in CellClick raises the OutOfBounds Exception it cannot be anything but a blatant bug. Since CellClick cannot be triggered on a non-displayed control, it cannot be an out of scope either. And I checked a click outside of a valid cell does not do anything.

If the run on the host does not do magic, only Greg is probably able to sort this out.

Well… No dice. I move virtually all code to the Session. I eliminated any open events and replaced with Shown events. all code in controls call methods in the Session. Per Michael Bujardet’s suggestion I put the two lines above separately in different builds and tested each variation but still get the same OutOfBoundsException from CellClick but I’ve ONLY ever gottent the error running on a build installed on the W2k8 web server running IIS. If I run a debug version in the IDE everything runs correctly as expected. If I put tat build in I get the exception in the CellClick or when scrolling a ContainerControl that contains a controlset of Images in a WebImageView controls. I somehow suspect the problem may be with the ContainerControl and/or the ControlSets within that ContainerControl. I guess the next step is to remove the ContainerControl or possibly the code that creates and populates the ControlSets.

Another weirdness is that in the IDE debug build the WebPage window size is correctly calculated to display a ProgressWheel horizontally and Vertically centered but the app does not calculate correctly when running on the Web Server build as well as the ContainerControl is the wrong size for the WebPage window. (Testing on a Windows 7 64 desktop).

Lastly all I do for a new build is delete the old executable and replace with the new build executable without making any further changes in the web server since I shouldn’t have to all other things being the same including Libs and Resources.

This is getting frustrating.

If you’re using the same version of the IDE each time, this is probably okay unless you add some code that adds another DLL to your project. If that happens, not copying the Libs folder will get you an app that probably won’t run anyway.

Do me a favor, in your JobSelected method, could you log the CurrentJobID and the ubounds of Session.JobData?


I have this sneaky suspicion that the one of these two pieces is not what you think it is.


I added the following lines to Session.JobData immediately following declarations.

Session.LogDebugData(Str(Ubound(Session.JobData,1))) Session.LogDebugData(Str(Ubound(Session.JobData,2))) Session.LogDebugData(Str(WebPage1.ListBox_Jobs.LastIndex))

And I added this logging method.

[code]LogDebugData(logdata As String)
Dim f As FolderItem
Dim t as TextOutputStream

f = GetFolderItem(“debuglog.txt”)

If Not (f = Nil) Then
If f.Exists Then
t = TextOutputStream.Append(f)
t.Write(logdata + EndOfLine)
t = TextOutputStream.Create(f)
End If
End If

Running my app in the IDE the output from application launch returns the expected result as did clicking on another cell.

4188 10 4188
as did clicking on another cell once the first collection of thumbnails were shown.

4188 10 4188 4188 10 4188

Running the app on my web server returned the same startup results as in the IDE…

4188 10 4188
but clicking on a cell causes the Unhandled OutOfBoundsException.

I’m stumped.

Greg I’d be happy to host a Webex and have you look at my code and what is going on with this if you’re interested.

Just wonder : are you running the debug on a Windows machine as well ?

Michael, Debug is on Windows 7 64 on a Dell UltraBook. The Web server is Windows server 2008 64 running on a VM server on Cisco UTS blades with a 10GB Network. The MySQL Server is on a separate Windows server 2008 64 also running on a VM server on Cisco UTS.

The plot thickens. I had hoped there was enough difference between the debug and build to explain the issue.

At this point, I think only Greg may be able to help. Good luck.

So have you in fact put:


At the top of the method that’s failing? I still think it’s either higher than the ubound or -1.