Thottam R. Sriram Code sample · MSDN blog archive

NTSD and SOS: StopOnException

blog-ntsd-stoponexception-sample read the blog post →

Test program for the SOS !StopOnException command. It throws OutOfMemoryException in a loop and a single ArgumentException on one iteration, so you can practice breaking only on the exception type you care about.

Source

program.cs C#
using System;
class Program
{
    static void Main(string[] args)
    {
        Program p = new Program();
        p.ExceptionSample();
    }

    private void ExceptionSample()
    {
        int i=0;
        while (i < 100)
        {
            if (i == 60)
            {
                try
                {
                    throw new ArgumentException();
                }
                catch (Exception)
                {
                }
            }
            else
            {
                try
                {
                    throw new OutOfMemoryException();
                }
                catch (Exception)
                {
                }
            }
            i++;
        }
    }
}

← All posts