Debugging
Fixing Errors
It is inevitable to encounter many errors while developing an application. The Visual Studio program gives the user various information about the source of the error.
When an error occurs in the application, this error is first shown to the user with a dialog window.
The “Yes” command must be selected to run the latest working build, ignoring the error. However, changes after the last working build will not be reflected in the run.
To clear the error, the “No” command should be clicked. In this case, it returns to the worksheet and the cause of the error is displayed in the Error List panel.
The Error List panel displays the cause of the error, the file where the error occurred, and the line number. The error can be fixed by going to this line.
In some cases, runtime-related errors may occur despite compilation. In this case, the error page screen will appear on the build page. On this page, the cause of the error is reported to the user at the top of the page.
In some cases, troubleshooting may not be as easy as stated above. The increase in the number of pages and accordingly the increase in the coding increases the probability of error.
Some methods that can be used to do error checking are as follows:
After making changes, compile the application and check if there is an error.
Do the compilation step by step with the command Debug > Start Without Debugging (Ctrl + F5).
Make the compilation by determining the working steps by adding breakpoints.
Using Breakpoints
Breakpoint is used to stop the application from running at the desired line of code.
To bugcheck with Breakpoint:
- Go to the line where you will add the breakpoint and use the Debug > Toogle Breakpoint (F9) command.
- A red dot will appear at the beginning of the line.
- Compile the application. The programming software compiles the application and waits until it reaches the first breakpoint.
- Use the Debug > Step Into (F11) or Debug > Step Over (F10) commands to move to the next step.
- While debugging step by step with Step Over (F10) command, if a method used etc. If there are, they cannot be entered. When the Step Into(F11) command is used, each one is entered. These commands are also available on the Debug toolbar.
Using Try – Catch – Finally