IndexOutOfRangeException

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hello,

I'm programming a application on a WINCE 4.2 device
In the mainform(frmMain) I start a thread in formload event which reads the
GPS coordinates from port1 (internal GPS-reciever)
the coordinates are stored in Global variables

After a while (everytime on a differenty time moment) I get the exception :

IndexOutOfRangeException
Application::Run+0xf
frmMain::Main+0xa

I can't debug the application on the device so it's hard to trap the
exception.

My question is : what exactly means the IndexOutOfRangeException ?, so that
I have a direction where to look and how to avoid the exception ?

Thanks for any input.

Peter.
 
Somewhere in your code you are accessing an indexed member typically in an
array which is outside the bounds. For example if you had a buffer
byte[] buffer = new byte[42];

You would get an exception if you tried to access
byte thisbyte = buffer[42];

Because this is the 43rd element in the array.

So somwhere in your code you are not correctly checking the size of an
array/collection before accessing it's members. To find where it is occuring
ideally you would connect the device up to your PC and run the code through
the debugger. You can also add some logging into your code to narrow down
the location of the exception.

Peter
 
Thanks Peter for the explanation, now I've got where to look for.

I can't debug on my device, but you suggest logging, do you mean writing to
a logfile(textfile) ?
which argument do I have to use with try / catch ?

I'm fairly new on C# and Visual Studio 2003.

Regards Peter.

Peter Foot said:
Somewhere in your code you are accessing an indexed member typically in an
array which is outside the bounds. For example if you had a buffer
byte[] buffer = new byte[42];

You would get an exception if you tried to access
byte thisbyte = buffer[42];

Because this is the 43rd element in the array.

So somwhere in your code you are not correctly checking the size of an
array/collection before accessing it's members. To find where it is occuring
ideally you would connect the device up to your PC and run the code through
the debugger. You can also add some logging into your code to narrow down
the location of the exception.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Peter said:
Hello,

I'm programming a application on a WINCE 4.2 device
In the mainform(frmMain) I start a thread in formload event which reads
the
GPS coordinates from port1 (internal GPS-reciever)
the coordinates are stored in Global variables

After a while (everytime on a differenty time moment) I get the exception
:

IndexOutOfRangeException
Application::Run+0xf
frmMain::Main+0xa

I can't debug the application on the device so it's hard to trap the
exception.

My question is : what exactly means the IndexOutOfRangeException ?, so
that
I have a direction where to look and how to avoid the exception ?

Thanks for any input.

Peter.
 
For logging info read this:
http://www.danielmoth.com/Blog/2004/11/debugwriteline.html

I don't understand your try catch question.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Peter said:
Thanks Peter for the explanation, now I've got where to look for.

I can't debug on my device, but you suggest logging, do you mean writing
to
a logfile(textfile) ?
which argument do I have to use with try / catch ?

I'm fairly new on C# and Visual Studio 2003.

Regards Peter.

Peter Foot said:
Somewhere in your code you are accessing an indexed member typically in
an
array which is outside the bounds. For example if you had a buffer
byte[] buffer = new byte[42];

You would get an exception if you tried to access
byte thisbyte = buffer[42];

Because this is the 43rd element in the array.

So somwhere in your code you are not correctly checking the size of an
array/collection before accessing it's members. To find where it is occuring
ideally you would connect the device up to your PC and run the code through
the debugger. You can also add some logging into your code to narrow down
the location of the exception.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Peter said:
Hello,

I'm programming a application on a WINCE 4.2 device
In the mainform(frmMain) I start a thread in formload event which reads
the
GPS coordinates from port1 (internal GPS-reciever)
the coordinates are stored in Global variables

After a while (everytime on a differenty time moment) I get the exception
:

IndexOutOfRangeException
Application::Run+0xf
frmMain::Main+0xa

I can't debug the application on the device so it's hard to trap the
exception.

My question is : what exactly means the IndexOutOfRangeException ?, so
that
I have a direction where to look and how to avoid the exception ?

Thanks for any input.

Peter.
 
Thanks Daniel,
I don't understand your try catch question.

Does the try catch trap all errors or do I have to specify which error I
want to trap.
I'm writing in C# so I guess the best way is to go with OpenNetCf because
the VB code is hard to understand for me.

Regards
Peter



Daniel Moth said:
For logging info read this:
http://www.danielmoth.com/Blog/2004/11/debugwriteline.html

I don't understand your try catch question.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Peter said:
Thanks Peter for the explanation, now I've got where to look for.

I can't debug on my device, but you suggest logging, do you mean writing
to
a logfile(textfile) ?
which argument do I have to use with try / catch ?

I'm fairly new on C# and Visual Studio 2003.

Regards Peter.

Peter Foot said:
Somewhere in your code you are accessing an indexed member typically in
an
array which is outside the bounds. For example if you had a buffer
byte[] buffer = new byte[42];

You would get an exception if you tried to access
byte thisbyte = buffer[42];

Because this is the 43rd element in the array.

So somwhere in your code you are not correctly checking the size of an
array/collection before accessing it's members. To find where it is occuring
ideally you would connect the device up to your PC and run the code through
the debugger. You can also add some logging into your code to narrow down
the location of the exception.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Hello,

I'm programming a application on a WINCE 4.2 device
In the mainform(frmMain) I start a thread in formload event which reads
the
GPS coordinates from port1 (internal GPS-reciever)
the coordinates are stored in Global variables

After a while (everytime on a differenty time moment) I get the exception
:

IndexOutOfRangeException
Application::Run+0xf
frmMain::Main+0xa

I can't debug the application on the device so it's hard to trap the
exception.

My question is : what exactly means the IndexOutOfRangeException ?, so
that
I have a direction where to look and how to avoid the exception ?

Thanks for any input.

Peter.
 
try{
// some code
}catch (IndexOutOfRangeException e1){
// log e1.ToString() and method name etc
}catch (Exception e2){
// log e2.ToString() and method name etc
}

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Peter said:
Thanks Daniel,
I don't understand your try catch question.

Does the try catch trap all errors or do I have to specify which error I
want to trap.
I'm writing in C# so I guess the best way is to go with OpenNetCf because
the VB code is hard to understand for me.

Regards
Peter



Daniel Moth said:
For logging info read this:
http://www.danielmoth.com/Blog/2004/11/debugwriteline.html

I don't understand your try catch question.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Peter said:
Thanks Peter for the explanation, now I've got where to look for.

I can't debug on my device, but you suggest logging, do you mean
writing
to
a logfile(textfile) ?
which argument do I have to use with try / catch ?

I'm fairly new on C# and Visual Studio 2003.

Regards Peter.

"Peter Foot [MVP]" <[email protected]> schreef in bericht
Somewhere in your code you are accessing an indexed member typically
in
an
array which is outside the bounds. For example if you had a buffer
byte[] buffer = new byte[42];

You would get an exception if you tried to access
byte thisbyte = buffer[42];

Because this is the 43rd element in the array.

So somwhere in your code you are not correctly checking the size of an
array/collection before accessing it's members. To find where it is
occuring
ideally you would connect the device up to your PC and run the code
through
the debugger. You can also add some logging into your code to narrow down
the location of the exception.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Hello,

I'm programming a application on a WINCE 4.2 device
In the mainform(frmMain) I start a thread in formload event which reads
the
GPS coordinates from port1 (internal GPS-reciever)
the coordinates are stored in Global variables

After a while (everytime on a differenty time moment) I get the
exception
:

IndexOutOfRangeException
Application::Run+0xf
frmMain::Main+0xa

I can't debug the application on the device so it's hard to trap the
exception.

My question is : what exactly means the IndexOutOfRangeException ?, so
that
I have a direction where to look and how to avoid the exception ?

Thanks for any input.

Peter.
 
Back
Top