This question already has answers here:
What kind of Exceptions cannot be handled? [duplicate]
(2 answers)
Closed 8 years ago.
So from http://msdn.microsoft.com/en-us/library/ms173161.aspx
Once an exception is thrown, it propagates up the call stack until a catch statement for the exception is found.
So the implcation is that all exception typess can be either caught by a catch(ExceptionType) or a generic catch.
However this is plainly not true. For example AccessViolationException bypasses standard exception handling
How to handle AccessViolationException
So what other exceptions also bypass standard exception handling?
I would say that a StackOverflowException is most likely unhandled, I'm not aware of others.
This question already has answers here:
How can I determine which exceptions can be thrown by a given method?
(9 answers)
Finding out what exceptions a method might throw in C#
(4 answers)
Closed 9 years ago.
Very simple really - is there a way to check and make a list of all exceptions that a method might throw? I have used try/catch but I want to make sure I didn't miss anything, and going through big files line by line to check if that line is throwing something that might be uncaught on runtime is a pain...
Oh yeah, I am using C#, .NET 4.5 and VS2012 PRO.
Thanks good people.
In C#, all objects that are thrown must derive from System.Exception. If you catch System.Exception, you catch them all, no matter what subtype.
This question already has answers here:
What do the "+n" values mean at the end of a method name in a stack trace?
(4 answers)
Closed 9 years ago.
I am trying to track down an exception thrown in a c# web app I have created and was wondering if someome could tell me what the + numbers relate to on each line in the stack trace
It's the offset from the start of the method, so the Exception is thrown 110 bytes (in IL) from the start of GetEmployee (which is not directly translatable to a line number due to compiling, jitting, inlining etc.)
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Say you are running a program,
and it meets a "THROW" statement... what happens?
Will the program stop? Will it continue?
And what's "FINALLY" for?
Please I appreciate an explanation in simple words
if program meeets throw instruction it will throw an exception.
Will your application stop or continue running depends on will you handle that exception ot not with catch instruction.
finally, instead, is introduced to guarantee the execution of the containing code inside that block either exception was thrown or not.
See the MSDN documentation for throw here: http://msdn.microsoft.com/en-us/library/1ah5wsex.aspx
In brief, throw raises an exception. If you are in a try-catch block then it will be caught, if not your program may crash.
The finally block executes after the try-catch block regardless of whether there was an exception which was thrown (and caught).
The throw statement is used to signal the occurrence of an anomalous situation (exception) during the program execution. Usually the throw statement is used with try-catch or try-finally statements. When an exception is thrown, the program looks for the catch statement that handles this exception.
The finally block is useful for cleaning up any resources allocated in the try block as well as running any code that must execute even if there is an exception. Control is always passed to the finally block regardless of how the try block exits.
Throw: http://msdn.microsoft.com/en-us/library/1ah5wsex(v=vs.80).aspx
Finally: http://msdn.microsoft.com/en-us/library/zwc8s4fz(v=vs.80).aspx
You find a lot of information here:
http://msdn.microsoft.com/en-us/library/ms173160(v=vs.80).aspx
Exceptions have the following properties:
When your application encounters an exceptional circumstance, such as a division by zero or low memory warning, an exception is generated.
Use a try block around the statements that might throw exceptions.
Once an exception occurs within the try block, the flow of control immediately jumps to an associated exception handler, if one is present.
If no exception handler for a given exception is present, the program stops executing with an error message.
If a catch block defines an exception variable, you can use it to get more information on the type of exception that occurred.
Actions that may result in an exception are executed with the try keyword.
An exception handler is a block of code that is executed when an exception occurs. In C#, the catch keyword is used to define an exception handler.
Exceptions can be explicitly generated by a program using the throw keyword.
Exception objects contain detailed information about the error, including the state of the call stack and a text description of the error.
Code in a finally block is executed even if an exception is thrown, thus allowing a program to release resources.
This question already has answers here:
Is there a way to log or intercept First Chance Exceptions
(3 answers)
Closed 5 years ago.
Is there a way to catch First-Chance exceptions, and log them without running under a debugger?
I suppose another way to ask the question is can I write something that will act like a debugger being attached to my process and see what is going wrong while it happens?
If you are on .NET 4.0, you can use theAppDomain.FirstChanceExceptionevent to get notification of exceptions.