20.5. Tracking Down a Runtime Error

This section analyzes an error that brings down a running page. When a page crashes at runtime, the compiler tells you what it knows about the problem. The information is usually helpful — but beware that it doesn't always point to the real source of the error. It often points to where it discovered the error.

When you run the test page again you get farther but, as shown in Figure 20-8, not far enough. The page seems to have crashed in the getText() function because of a missing object instance.

Figure 20-8. An object reference error at runtime.

To track down the error with the debugger, follow these steps:

  1. Open the ASP.NET page in Source view.

  2. Delete any existing breakpoints (DebugDelete All Breakpoints; click OK).

  3. Set a new breakpoint (F9) at the following line:

    Function getText() As String()

    For more on breakpoints, see the previous section, "Setting a breakpoint in the code."

  4. Start debugging (F5) and wait until the execution stops at the breakpoint.

  5. Open the Locals pane (DebugWindows Locals).

  6. Watch the values in the Locals pane and step into the function ...

Get ASP.NET 3.5 For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.