Exception problem

  • Thread starter Thread starter gh
  • Start date Start date
G

gh

Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has some
unexpected behaviours. After adding try-catch block to many pieces of code.
It catches an array index out of bound exception. I am using VS.Net 2003 and
is there any way to avoid this?

Regards,
Aaron
 
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would
you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
 
My program had an array index out of bound problem. I didn't write any
try-catch block to capture this exception. It is supposed that an run time
exception should be thrown and the program terminates. But for my case, it
is not. After adding the try-catch block, the program catches the exception.


Alvin Bruney said:
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would
you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


gh said:
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has
some unexpected behaviours. After adding try-catch block to many pieces
of code. It catches an array index out of bound exception. I am using
VS.Net 2003 and is there any way to avoid this?

Regards,
Aaron
 
Is it possible that the exception is occurring inside of an event handler?
If so, you may have to handle it yourself. In any case, or course, you
should be able to avoid the exception by ensuring that the array size is
never exceeded.


gh said:
My program had an array index out of bound problem. I didn't write any
try-catch block to capture this exception. It is supposed that an run time
exception should be thrown and the program terminates. But for my case, it
is not. After adding the try-catch block, the program catches the
exception.


Alvin Bruney said:
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would
you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


gh said:
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has
some unexpected behaviours. After adding try-catch block to many pieces
of code. It catches an array index out of bound exception. I am using
VS.Net 2003 and is there any way to avoid this?

Regards,
Aaron
 
If you don't use a try-catch then when an exception occurs it becomes an
unhandled exception (UE). The behavior of the system is then determined by
the type of thread the UE occurred on. If it is your main thread then the
program will terminate.

gh said:
My program had an array index out of bound problem. I didn't write any
try-catch block to capture this exception. It is supposed that an run time
exception should be thrown and the program terminates. But for my case, it
is not. After adding the try-catch block, the program catches the
exception.


Alvin Bruney said:
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would
you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


gh said:
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has
some unexpected behaviours. After adding try-catch block to many pieces
of code. It catches an array index out of bound exception. I am using
VS.Net 2003 and is there any way to avoid this?

Regards,
Aaron
 
If your program was throwing an exception, and you weren't catching it, how
do you know it was throwing it?

And if you add an exception handler, and the system starts catching an
error, how do you know you didn't ADD the error when you added the exception
handler?

In other words, a CLR bug is far less likely than a bug that you added in
your app when you added exception handling.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
gh said:
My program had an array index out of bound problem. I didn't write any
try-catch block to capture this exception. It is supposed that an run time
exception should be thrown and the program terminates. But for my case, it
is not. After adding the try-catch block, the program catches the exception.


"Alvin Bruney [MVP]" <vapor at steaming post office> ¼¶¼g©ó¶l¥ó·s»D:[email protected]...
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would
you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


gh said:
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has
some unexpected behaviours. After adding try-catch block to many pieces
of code. It catches an array index out of bound exception. I am using
VS.Net 2003 and is there any way to avoid this?

Regards,
Aaron
 
Back
Top