Walkthrough: Debugging an XML Web Service
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Walkthrough: Debugging an XML Web Service

The steps in this walkthrough will show you how to debug an XML Web service. It will show you how to start and stop execution and set breakpoints.

NoteNote

By default, the ASP.NET process, using either aspnet_wp.exe or w3wp.exe, runs under the ASP.NET account. As a result, you must have Administrator privileges on the machine where ASP.NET runs to debug it. For more information see ASP.NET Debugging: System Requirements.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To prepare for this walkthrough

  • If you already have an solution open, close it.

To create and debug an XML Web service

  1. From the File menu, click New, and click Web Site.

    The New Web Site dialog box appears.

  2. In the Templates pane, select ASP.NET Web Service. You can now specify a directory on your local machine, or a URL to a remote machine.

  3. In the Location drop-down list, select File System, and in the text box type the directory on your local machine where the XML Web service will be located, and specify a unique directory name, such as Website1. The XML Web service will have the same name as the directory. If you wanted, you could put the directory on a remote server, or explore other options by clicking the Browse button.

  4. In the Language drop-down list, select the language you will use.

  5. Click OK.

    Visual Studio creates a new project and displays code for Service.cs, a template.

  6. Click the margin next to the line:

    ' Visual Basic 
        Return "Hello World"
    

    -or-

    // C#
        return "Hello World";
    

    A red dot appears and the text on the line is highlighted in red. The red dot represents a breakpoint. When you run the application under the debugger, the debugger will break execution at that location when the code is hit. You can then view the state of your application and debug it. For more information, see Breakpoints.

  7. Verify that the Active Configuration is the Debug configuration.

  8. From the Debug menu, select Start or press F5.

  9. The Debugging Not Enabled dialog box appears. Select the Add a new Web.config file with debugging enabled option, and click OK.

  10. Internet Explorer opens, and displays the link Hello World.

  11. Click the Hello World link.

    A new page opens in Internet Explorer.

  12. On the new page, click the Invoke button.

    At this point, you will hit the breakpoint in Visual Studio. You can now evaluate variables in the Watch window, view local variables, and step through your code.

  13. From the Debug menu, click Stop Debugging.

To attach to the XML Web service for debugging

  1. In Visual Studio, you can attach the debugger to a running process. The following procedure shows how to do this.

  2. In the current project, click in the margin next to the line that contains the following code:

    ' Visual Basic 
        Return "Hello World"
    
    // C#
        return "Hello World";
    

    This sets a breakpoint. You should see a red dot appear in the margin and red highlighting on the line of code.

  3. From the Debug menu, select Start Without Debugging.

    The XML Web service starts running under Internet Explorer, but the debugger is not attached.

  4. From the Debug menu, select Attach to Process. You can also click Attach to Process on the Tools menu.

  5. Click Show processes from all users.

    NoteNote

    If you are debugging in a Terminal Services or Remote Desktop session, you must also select Show processes in all sessions.

  6. In the Available Processes pane, find WebDev.WebServer.EXE in the Process column, and click it.

    The WebDev.WebServer.EXE process loads your code and displays it in Internet Explorer.

  7. Click the Attach button.

    You have attached the debugger to your running Web service.

  8. In Internet Explorer, click the line that says "Hello World".

    A new page opens.

  9. On the new page, click the Invoke button.

    At this point, you hit the breakpoint in Visual Studio. You can now evaluate variables in the Watch window, view locals, and step through your code.

Show:
© 2016 Microsoft