471,350 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Exception problem

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
Jul 21 '05 #1
5 1524
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" <gh******@FSAF.COM> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
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

Jul 21 '05 #2
gh
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> 撰寫於郵件新聞:uH**************@TK2MSFTNGP12.phx.g bl...
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" <gh******@FSAF.COM> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
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


Jul 21 '05 #3
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" <gh******@FSAF.COM> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
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>
撰寫於郵件新聞:uH**************@TK2MSFTNGP12.phx.g bl...
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" <gh******@FSAF.COM> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
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



Jul 21 '05 #4
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" <gh******@FSAF.COM> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
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>
撰寫於郵件新聞:uH**************@TK2MSFTNGP12.phx.g bl...
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" <gh******@FSAF.COM> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
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



Jul 21 '05 #5
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" <gh******@FSAF.COM> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
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>

撰寫於郵件新聞:uH**************@TK2MSFTNGP12.phx.g bl...
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" <gh******@FSAF.COM> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
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



Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by P嫮l 胵afsson | last post: by
3 posts views Thread by Tony Johansson | last post: by
3 posts views Thread by Professor Frink | last post: by
16 posts views Thread by ChInKPoInt [No MCSD] | last post: by
44 posts views Thread by craig | last post: by
40 posts views Thread by Kevin Yu | last post: by
5 posts views Thread by Nick Flandry | last post: by
7 posts views Thread by Chuck Hartman | last post: by
3 posts views Thread by Robert Rawlins | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.