Debugging is a large topic. We won’t go into in much detail here.

If you are accustomed to Arduino programming, then you have likely used Serial.print statements to add a debugging trace to your sketches. Visual Studio and IoT Core applications do things differently. Instead of print statements, you set breakpoints in your code.

With breakpoints, you tell Visual Studio where to pause in executing your code. Once the code pauses, you can use Visual Studio to look at the values of variables. You can also single-step through your code line-byline, so that you can see the order of operations.

This form of debugging is much quicker and much more effective than using print statements.

Set a breakpoint by clicking in the gray bar to the left of the line you want to pause on:

Here, we’ve set a breakpoint on the if statement in Timer_Tick. Visual Studio will pause the application just before we execute this line. We can then do things like look at the value of the variable pinValue, simply by hovering the cursor over the word pinValue.

We can also single step, using the debugger toolbar:

The stepping icons are to the right of the picture.

  • The down arrow over the dot is step into. If there is a function call on the line, clicking this button will step into the function and pause again on the first line of the function.
  • The curved arrow over the dot is step over this will step to the next line in the code, but won’t step into any functions called on the line.
  • The up arrow over the dot is step out. It causes the code to proceed until the current function is exited. It will then pause again on the first line after the function call.
  • Other buttons to note are the green Continue button, which resumes normal execution from the breakpoint . The red square will immediately terminate your app. The circular arrow will restart your app from the beginning.

Next steps

That's pretty much it for our headless application.  If all went well, your LED should be merrily blnking away.  If not, help is always available in the forums!

Next, we'll go through the Headed version of Blinky

This guide was first published on Aug 03, 2016. It was last updated on Jul 14, 2016.

This page (Debugging) was last updated on Jul 14, 2016.

Text editor powered by tinymce.