By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,986 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,986 IT Pros & Developers. It's quick & easy.

Exceptions that Cannot be Caught

P: n/a
Hi All,
Are there any sort of exceptions that cannot be caught
by the Runtime, Any Insights?
Thanks in Advance
thomson

May 13 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi
If you are writting managed Code and using proper try catch block then there
is no such exception which cannot be caught. Yes, But sometimes it happens
that you have written correct try catch block but exception is still
unhandled. This type of exception is called First Chance Exception. As you
can come across it while developing web services or working with threads.

Now What is a first chance exception?
When an application is being debugged, the debugger gets notified whenever
an exception is encountered At this point, the application is suspended and
the debugger decides how to handle the exception. The first pass through this
mechanism is called a "first chance" exception. Depending on the debugger's
configuration, it will either resume the application and pass the exception
on or it will leave the application suspended and enter debug mode. If the
application handles the exception, it continues to run normally.
"thomson" wrote:
Hi All,
Are there any sort of exceptions that cannot be caught
by the Runtime, Any Insights?
Thanks in Advance
thomson

May 13 '06 #2

P: n/a
Some exceptions can't be caught by a try...catch block surrounding the
code because of the way that Windows Forms works, and the way that the
message pump works within Windows: a WinForms application running on
its own (not under the debugger) works differently than it does running
under the debugger, which can cause some confusion.

However, to address the direct question: are there any exceptions that
absolutely cannot be caught by any means? The only one I can think of
offhand is StackOverflowException, since a catch block, or any of the
global exception handlers you can write require stack space in order to
execute. If you're out of stack you can't call anything... including an
exception handler.

May 13 '06 #3

P: n/a
Altaf,

Yes, there are some very critical exceptions that cannot be cought e.g
ExecutionEngineException (there are couple more that depending on the
internal state the runtime the application may or may not be able to catch).

Also exceptions can only be cought usng try/catch in the same thread where
the exception is thrown. For example if the main thread starts a worker
thread and in the worker thread there is unhandled exception it won't bubble
to the main thread.
--

Stoitcho Goutsev (100)

"Altaf Al-Amin Najwani" <al**********@gmail.com> wrote in message
news:FD**********************************@microsof t.com...
Hi
If you are writting managed Code and using proper try catch block then
there
is no such exception which cannot be caught. Yes, But sometimes it happens
that you have written correct try catch block but exception is still
unhandled. This type of exception is called First Chance Exception. As you
can come across it while developing web services or working with threads.

Now What is a first chance exception?
When an application is being debugged, the debugger gets notified whenever
an exception is encountered At this point, the application is suspended
and
the debugger decides how to handle the exception. The first pass through
this
mechanism is called a "first chance" exception. Depending on the
debugger's
configuration, it will either resume the application and pass the
exception
on or it will leave the application suspended and enter debug mode. If the
application handles the exception, it continues to run normally.
"thomson" wrote:
Hi All,
Are there any sort of exceptions that cannot be caught
by the Runtime, Any Insights?
Thanks in Advance
thomson

May 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.