Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining which code line threw the exception

In dotNet a line throws an exception and is caught, how can I figure out which line in which file threw the exception? Seems relatively straightforward, but I can't figure it out...

like image 270
Matt Avatar asked Jun 29 '09 00:06

Matt


1 Answers

You can only do it if you have debug symbols available.

catch(Exception ex) {
    // check the ex.StackTrace property
}

If you want to debug such a situation in VS, you'd better just check Thrown checkbox for Common Language Runtime Exceptions in Exceptions dialog located in Debug menu. The debugger will break as soon as the exception is thrown, even if it's in a try block.

like image 195
mmx Avatar answered Sep 18 '22 10:09

mmx