A Simple Example

Let's load up the example from Chapter 1, “Creating Your First Web Service,” and set a breakpoint within the GetRandomNumbers function. As you may recall, that function returns a variable number of random numbers that all lie within a range as requested by the user. If we want to debug this method, we just open up the Chapter1 project and set a breakpoint within the GetRandomNumbers function, as shown in Figure 5.10.

Figure 5.10. Setting a breakpoint in GetRandomNumbers.


With a breakpoint set, we next need to attach to the aspnet_wp.exe process, as shown in Figure 5.8. Doing so attaches the debugger and allows us to be notified when the breakpoint is hit. To generate a call, we can either fire up one of the applications from Chapter 2, “Consuming Your Web Service,” or invoke the method from the ASP .NET-generated Web page. How we do it does not matter—from the debugger the call will look the same. So, I navigate to http://localhost/Chapter1/FirstService.asmx?op=GetRandomNumbers and load up the parameters with the values set as

  • arraySize: 5

  • min: 1

  • max: 20

This means that I want the method to return 5 random values between 1 and 20. With this data entered, I click Invoke and see the debugger stop on the breakpoint. From here, I can inspect variables, step into any functions I have source code for, and perform any other debugging functions. Before leaving the chapter, try setting breakpoints in the other methods to make sure that you are familiar with how to set a breakpoint, attach to aspwnet_wp.exe, and step through a method.

When you are finished debugging, either stop debugging or exit the development environment. You will find that debugging is easiest on Windows XP, because XP allows you to attach and detach from a process. When detaching from a process under Windows 2000, .NET has to perform some extra tricks. This is because Windows 2000 (and earlier Windows versions) do not provide a mechanism to detach from a process without killing that process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.187.210