开发者

put an exception to an exception to get the next exception on .net

开发者 https://www.devze.com 2023-01-19 09:06 出处:网络
I use thrown in visual studio 2005 while debugging a project to getthe possible error. But when I do it, it stops with an green arrow pointing the error line that is happening, but I want to skip tha

put an exception to an exception to get the next exception on .net

I use thrown in visual studio 2005 while debugging a project to get the possible error.

But when I do it, it stops with an green arrow pointing the error line that is happening, but I want to skip that error to get the next possible error. How can I skip and set the yellow arrow to make it yellow and let it to go on to the part of the code lines..

How can I do开发者_StackOverflow it?


You can put a break point on the exception and when you get to that line you can go to the next statement (assuming you know it is safe to do so) and right-click and select 'Set Next Statement'.


Once an unhandled exception has been thrown the normal execution of your program ends so there is no way to 'skip it' and move on.
For debugging purposes if you want you program to carry on executing regardless of this exception you could surround the section of code that is causing the problem in a try/catch block and just ignore the exception although this is not good practice for production code.

try
{
   // code causing exception
}
catch (Exception ex)
{
   // Ignore of log exception
}

As mentioned before this is not good practice for production code. Exceptions should ideally be handled when thrown and not ignored. Failure to do so could lead to all sorts of hard to debug problems down the line but for debugging purposes, if you need to see further into the program execution, this may help.

0

精彩评论

暂无评论...
验证码 换一张
取 消