I have a problem debugging Invoke()
or BeginInvoke()
in Visual Studio 2008.
For instance in the code below the debugger breaks on the Invoke()
call. I would have liked it to break on Console.WriteLine(p.ToString());
because that is where an exception is thrown. In code as simple as this this is not that much of a problem but it can get really annoying in more complex code. (With BeginIvoke()
things even get worse because then the debugger breaks on Application.Run(new Form1());
)
Is there any way to make the debugger break at the location of the original exception?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Invoke(new Action(MyMethod));
}
private void MyMethod()
{
object p = null;
Console.WriteLine(p.ToString());
}
}