Walkthrough: Debugging an XML Web Service
This topic applies to:
Pro and Team
Does not apply
Command or commands hidden by default.
The steps in this walkthrough will show you how to debug an XML Web service. You will learn how to start and stop execution and set breakpoints.
By default, the ASP.NET process, using either aspnet_wp.exe or w3wp.exe, runs under the ASP.NET account. Therefore, you must have Administrator privileges on the computer where ASP.NET runs in order to debug it. For more information, see ASP.NET Debugging: System Requirements.
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 create and debug a Web service
On the File menu, click New, and then click Web Site.
The New Web Site dialog box appears.
In the Templates pane, select ASP.NET Web Service. You can now specify a directory on your local computer, or a URL to a remote computer.
In the Location drop-down list, select File System, and in the text box type the directory on your local computer where the Web service will be located.
Specify a unique directory name, such as Website1.
The Web service will have the same name as the directory. You can put the directory on a remote server, or explore other options by clicking Browse.
In the Language drop-down list, select the language you will use.
Visual Studio creates a new project and displays code for Service.cs, a template.
Click the margin next to the line:
' Visual Basic Return "Hello World"
// 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.
Verify that the Active Configuration is the Debug configuration.
On the Debug menu, select Start or press F5.
The Debugging Not Enabled dialog box appears. Select the Add a new Web.config file with debugging enabled option, and click OK.
Internet Explorer opens, and displays the link Hello World.
Click the Hello World link.
A new page opens in Internet Explorer.
On the new page, click Invoke.
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.
On the Debug menu, click Stop Debugging.
To attach to the Web service for debugging
In Visual Studio, you can attach the debugger to a running process. The following procedure shows how to do this.
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.
On the Debug menu, select Start Without Debugging.
The Web service starts to run under Internet Explorer, but the debugger is not attached.
On the Debug menu, select Attach to Process. You can also click Attach to Process on the Tools menu.
Click Show processes from all users.
If you are debugging in a Terminal Services or Remote Desktop session, you must also select Show processes in all sessions.
In the Available Processes pane, find WebDev.WebServer.EXE in the Process column, and then click it.
The WebDev.WebServer.EXE process loads your code and displays it in Internet Explorer.
You have attached the debugger to your running Web service.
In Internet Explorer, click the line that says "Hello World".
A new page opens.
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.