I have a console application written in C# code. Let's assume that it's the most simple application just like Hello World example:
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException +=
CurrentDomain_UnhandledException;
int zero = 0;
int i = 10 / zero;
}
static void CurrentDomain_UnhandledException(
object sender, UnhandledExceptionEventArgs e)
{
Console.WriteLine("exception");
}
}
However, I want to handler the DevideByZero
exception in the global exception handler, but without exiting the application through Environment.Exit()
.
Is it possible at all? How?
Note:
I've already seen these questions, but they're all terminating. The exception gets raised again and again.