VS Go to error line in catch()

zequion 91 Reputation points

When an error occurs in a block that is inside a try{}catch{}, how can I go back to the line that produced it?

Microsoft Technologies based on the .NET software framework.
3,324 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jiale Xue - MSFT 28,626 Reputation points Microsoft Vendor

    Hi @zequion , Welcome to Microsoft Q&A,

    Updated: You need to generate a .pdb file to know the line number.

    You can try the following:

    Breakpoints: Set a breakpoint at the line of code where you suspect the error will occur. When program execution reaches a breakpoint, it pauses, allowing you to examine the current variable values and program state.

    Exceptions Window: When an exception is caught, Visual Studio lists it in the Exceptions Window. You can view the details of the exception, including error message, stack trace, and more.

    Debug output: In the catch block, you can use methods such as Debug.WriteLine() or Console.WriteLine() to output error messages or other debugging information. This can help you view exception information in the console or output window.

    "Continue" and "Step Out": During debugging, you can choose "Continue" or "Step Out" to continue executing the program or jump out of the current function.

    Best Regards,


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

  2. zequion 91 Reputation points

    Apparently I need to generate a .pdb file to know the line number. I thought VS already allowed you to go backwards.

    0 comments No comments