c# Windows Forms Application Exception not thrown!

Viewed 3068

I have a strange problem, will appreciate if anyone can help.

I have the following function:

void Foo()
{
    MessageBox.Show("here");
    throw new Exception();
}

I call it in the following two cases (separately - not at the same time):

private void Form2_Load(object sender, EventArgs e)
{
     // Case 1
     Foo();
}

public Form2()
{
    InitializeComponent();

    // Case 2
    Foo();
}

I can see the messagebox (I receive message "here") in both case but:

[Case 1] The application doesn't break on the exception (in Debug mode) and remains silent!

[Case 2] Application correctly breaks and I can see that there is an exception in the Foo().

Any idea why?

2 Answers
Related