VS Go to error line in catch()

zequion 91 Reputation points
2024-03-05T02:42:45.32+00:00

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

.NET
.NET
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
    2024-03-05T06:12:33.87+00:00

    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,

    Jiale


    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
    2024-03-05T10:27:39.0966667+00:00

    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