I have a desktop application that was written using Real Basic then converted to Xojo. Simple timer with a serial IO to turn a motor on and off. The app runs great here in the States installed on over 30 computers ranging from Windows XP to Windows 8. I sent the app to a friend that is in Brussels he installed it and gets a [quote]An exception of class OutOfBoundsException was not handled. The application must shut down[/quote] He is using Windows 7 SP1 Enterprise - English.
I can’t duplicate the error here and we have gone through his laptop to see if he has any out of the norm apps installed but doesn’t.
I have re built and re zipped the app 3 or 4 times and sent to him over email and also wetransfer.com to make sure it was not a file corruption problem.
At this point I am scratching my head. Any help or suggestions as what to try next would be greatly appreciated.
Here is a shot in the dark: there is a date issue in your program. Your program probably uses US format dates. On Windows, British English (I believe) uses ddmmyyyy, while US English uses mmddyyyy. Any array or loop using the month will likely go out of bounds with months 13 through 31…
ah, yes! A very likely possibility indeed. I had that one with a VB program several years ago. I forget the exact API calls, but I fixed this issue with calls to the system to get the default separator, decimal, etc.
Here is the code that only he is having problems with.
[code] #if TargetWin32 then
if System.SerialPortCount <> lastSerialCount then
dim i, j, listCount, serialCount as Integer
serialCount = System.SerialPortCount
listCount = MenuBar1.Child( "DeviceMenu" ).Child( "DeviceConnectTo" ).Count
for i = 0 to listCount -1
try
MenuBar1.Child( "DeviceMenu" ).Child( "DeviceConnectTo" ).Remove(i)
catch err as OutOfBoundsException
end try
next
if serialCount > 0 then
for j = 0 to serialCount - 1
try
MenuBar1.Child( "DeviceMenu" ).Child( "DeviceConnectTo" ).Append(new serialItem(System.SerialPort( i ).Name))
catch err as OutOfBoundsException
end try
next
end if
lastSerialCount = System.SerialPortCount
end if
for i = 0 to listCount -1
try
MenuBar1.Child( "DeviceMenu" ).Child( "DeviceConnectTo" ).Remove(i)
catch err as OutOfBoundsException
end try
next
You certainly get an OutOfBoundsException here.
If you have listCount = 4 and remove items at the “beginning”, then there won’t be 4 items left when you’re at i=3.
Go the other way around when removing items:
for i = listCount -1 DownTo 0
Sure, you’re catching this exception here.
Is this code by any chance in a Modal Dialog?
I just ask because the Windows Framework has some issues with catching exceptions… One example: <https://xojo.com/issue/8646>
Thanks for all your help.
Mr. Norman Palardy - I have added If error <> Nil Then
Dim type As String = Introspection.GetType(error).Name
MsgBox(type + EndOfLine + EndOfLine + Join(error.Stack, EndOfLine))
End If to App.UnhandledException event - Thank you
Mr. Louis Desjardins - I tried changing the date and time format of my computer to see if the error could be reproduced, I wasn’t able to but I am suggesting to my friend in Brussels to try and change his. - Thank you
Mr. Bob Coleman - I am suggesting we try and change his date, time, separator, etc. to match my machine exactly - Thank you
Mr. Jürg Otter - I have changed the for statements to count down instead of up - Thank you (This code is running in the events of a timer on the mainWindow of the app)
With the time difference between California and Brussels, it will not be until tomorrow that I can get the results of the suggestions and re-build of the application. I will post when I have the results in.
if serialCount > 0 then
for j = 0 to serialCount - 1
try
MenuBar1.Child( "DeviceMenu" ).Child( "DeviceConnectTo" ).Append(new serialItem(System.SerialPort( i ).Name))
catch err as OutOfBoundsException
end try
next
end if
lastSerialCount = System.SerialPortCount
end if
Shouldn’t you be using SerialPort( j ) when appending the menu item?
OK Problem solved the reason the program crashed on his machine was the Windows date/time format specifically the ShortTime format. He changed it to h:mm tt and the application worked.
Now I have to figure out how to check the format and normalize the results.
Thanks
P.S.
Mr. Wayne Golding you are correct it should be a (j) I have changed to that Thank you.
You may want to look at the new Xojo.Core.Date class. It is available in all project types now and has better handling of user specified date/time formats.