I am using the YAX Serializer (current NuGet version). When I run this code:
void Main()
{
    try
    {
        int zero = 0;
        int result = 100 / zero;
    }
    catch (DivideByZeroException ex)
    {
        LogSaveException(ex);
    }
}
public void LogSaveException(object value)
{
    try
    {
        YAXSerializer serializer = new YAXSerializer(value.GetType());
        string loggedString = serializer.Serialize(value);
        Console.WriteLine(loggedString);
    }
    catch (StackOverflowException)
    {
        Console.WriteLine("Log Error", "Could Not Log object of type " 
                  + value.GetType().ToString() +" due to stack overflow.");
    }
    catch (Exception)
    {
        Console.WriteLine("Log Error", "Could Not Log object of type " 
                + value.GetType().ToString());
    }
}
The app ends on this line: string loggedString = serializer.Serialize(value);
I have tried to catch any exception that I can see would happen. But the app just ends.
I tried running it in LinqPad and it crashed LinqPad. I tried to debug the crash of LinqPad (even though I do not have the source, sometimes you can get some info from it.) When I did that it said that there was a StackOverflowException. But my catch statement did not catch it.
What would cause a total death like that? How how do I guard against it?
 
     
     
    