crazy novice
crazy novice

Reputation: 1817

Why I don't get a dump file for first chance exception

Here is the code that should be generating a first chance exception.

class MyClass
{
    public string SomeField { get; set; }
}
class Program
{
    static void Main(string[] args)
    {

        try
        {
            Print(null);
        }
        catch { }

    }


    static void Print(MyClass myclass)
    {
        Console.WriteLine(myclass.SomeField);
    }
}

I setup ProcDump to capture crash dumps as follows.

ProcDump -ma MyApplication.exe

To my understanding, this command should capture first chance and second change exceptions both. However with code above I don't get any exception. If remove the catch block from my code then I do get a dump file but should be a second chance exception. Any ideas why I don't get any crash dump for first chance?

Upvotes: 1

Views: 998

Answers (1)

Hans Passant
Hans Passant

Reputation: 941565

You are not using it correctly, it isn't shy about telling you that. Change your code to:

static void Main(string[] args) {
    Console.WriteLine("Okay, start ProcDump now and press Enter");
    Console.ReadLine();
    try {
        Print(null);
    }
    catch { }
}

Consider DebugDiag as an alternative.

Upvotes: 3

Related Questions