C# stop on error line within try catch -
this question has answer here:
if run code below calls test1(), vs2012 break nicely @ line , show me what's going on. if comment out test1 , put in test2, try catch not stop on line, logs out console.
how can vs2012 stop on error line, when surrounded try catch statement?
private void button_click(object sender, routedeventargs e) { //test1(); // no try catch - stops on error line dividing zero. test2(); // try catch - writes out console. } private void makeerror() { int = -1; += 1; int j = 1 / i; console.writeline(j.tostring()); } void test1() { console.writeline("makeerror in test1"); makeerror(); } void test2() { console.writeline("makeerror in test2"); try { makeerror(); } catch (exception ex) { console.writeline(ex.message); } }
while other answers correct, intentional behavior default, can tell visual studio alert exceptions if wish.
how to: break when exception thrown:
on debug menu, click exceptions.
in exceptions dialog box, select thrown entire category of exceptions, example, common language runtime exceptions.
-or-
expand node category of exceptions, example, common language runtime exceptions, , select thrown specific exception within category.
Comments
Post a Comment