views:

72

answers:

2

I am using the debugger (vs2008).

Once I've stepped into a catch statement, I would like to know if there is any way to set the execution cursor back to the beginning of the try.

Just dragging it there doesn't seem to work, is there some setting I need to change?

Example:

Try //Want the cursor back here
{

}
Catch
{
 some code // cursor is here....
}
A: 

You can't set the cursor on the try line. It will be on the line following immediately after it (the opening of the block statement).

Dragging the cursor to that line or the try line works fine for me in Visual Studio 2008. Can you provide a minimum code example that produces the problem for you?

This worked for me:

try
{
    throw new Exception();
}
catch
{
    Console.WriteLine("Error");  // Breakpoint here
}
Thorarin
+1  A: 

If I right click and do "set next statement" then I get the following error dialog:

Unable to set the next statement to this location. The attempt to unwind the callstack failed.

Unwinding is not possible in the following scenarios:

  1. Debugging was started via Just-In-Time debugging.
  2. An unwind is in progress.
  3. A System.StackOverflowException or System.Threading.ThreadAbortException exception has been thrown.

By elimination the reason why you cant move the cursor (The same as setting the next statement) must be #2.

Kragen