try/catch in C#

P

pack

Is "catch" in C# going to catch all exception, or it just catch the
exceptions induced by "throw"? Will it also catch those "structured
exceptions" that could be either from system modules or other DLL or COM
objects of native code?

If seeing a dialog of this:

"Unhandled exception at 0x8f345690 in vsdv.exe: 0xC0000005. Access violation
reading location 0x02313000."

Can we assume that this is a "structured exception" if all the managed code
has try/catch in place?
 
M

Michael Nemtsev

Hello pack,

p> Is "catch" in C# going to catch all exception, or it just catch the
p> exceptions induced by "throw"?

What's the "all exeptions"?
Catch handles all managed exception

p> Will it also catch those "structured
p> exceptions" that could be either from system modules or other DLL or
p> COM objects of native code?

Yep, but CLR is responsible for pick them up and wrapping into managed exception

p> If seeing a dialog of this:
p> "Unhandled exception at 0x8f345690 in vsdv.exe: 0xC0000005. Access
p> violation reading location 0x02313000."
p> Can we assume that this is a "structured exception" if all the
p> managed code has try/catch in place?

Not sure about this.
As I said before SEH is wrapper by CLR and u can end up with error throw
where u not expect it.
For this case u need provide handling of unhandled expection with appdomain.CurrentDomain.UnhandledException


I recommed to read this http://blogs.gotdotnet.com/cbrumme/archive/2003/10/01/51524.aspx
where detailed unmanaged and managed exception handling is explained

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top