Visual Studio Debugger

The exception is System.NullReferenceException occured. The additional information is object reference not set to an instance of object.

Visual studio will highlight the line of code where error occured.

We could use "Autos" window to display the variable that being used in this program.

It can be seen that our "Model" property is "null". So, how we could access the DisplayText function if our Model is null? That is the problem.

  1. Press "Continue" button to continue the website running.
  2. Back to Controller class. There is a feature of VS called Breakpoints. It breaks the process of building our project.
  3. Set the breakpoints in if statement.
  4. Refresh the page in browser.
  5. In "Autos" window, we could see that our "id" variable has a value.
  6. Notice there are buttons to help us in analyzing each line of code. There are step into, step over, and step out.
  7. Try to use step over button.
  8. Notice that comicBook variable is null and that causes an error.
  9. Press step Into button to check the function.
  10. Take a look at if conditional statement and use the debugger. It shows that our "id" is 1 but our "comicbook.id" is 0.
  11. Try to solve it.

results matching ""

    No results matching ""