Visual Studio – Debug and test application

Debug and test the application:

Next, we will debug the application to look for errors and test that message box appears correctly.

To start debugging and find error. Start the debugger by selecting Debug, then Start Debugging.

Or you can press F5 to start debugging.

You should see the following image:

visual-studio-form-message box

 Debug with breakpoints:

By adding some breakpoints, you can test the code during debugging. You can add breakpoints by choosing DebugToggle Breakpoint on the menu bar or by clicking in the left margin of the editor next to the line of code where you want the break to occur.

  • Clicking in the left margin of the editor next to the line of code to add break point. Refer to following image for the same:
  • In the menu bar choose to debug to debug this application
  • Click on the button, the line: MessageBox.Show (“Welcome User”) is highlighted in yellow. Similar to the following image.

Build a release version of the application.

To build a release version

  • Select build, then the clean solution to delete intermediate files and output files that were created during previous builds.
  • Change the build configuration for WindowFormApplication1 fromDebug to Release.