How to debug a web service in a C#/.NET solution f

2019-06-16 08:11发布

问题:

I have an application solution consisting of eight projects in C#/.NET with Web services.

One of the projects is of web services.

All the data is fetched through the web services in a Windows Forms application.

But while debugging my Windows application I am unable to debug the web services called for fetching the data in Visual Studio 2010.

How do I debug a web services project in a solution when data fetching events are fired?

回答1:

Normally, when debugging in Visual Studio the selected StartUp project will be executed in debug mode. In your case you need to start and debug both the Web API project as well as the WinForms project. You can do that by right-clicking in the solution explorer and selecting Set StartUp Projects. A dialog box opens where you can select Multiple startup projects and then select which projects to start when debugging the solution.

Another option is to have a single StartUp project (the Web API project as this is a requirement for the other project to run). You can then right-click on the WinForms project in the solution explorer and select Debug -> Start new instance. You can do this multiple times to debug multiple instances of the same project.

Obviously, you can always attach the debugger to any running process and if your Web API is deployed using IIS it will already be running. Using the procedure outlined above Visual Studio will attach to the right worker process.



回答2:

You can debug the web service by attaching the VS debugger to a process as follows:

Debug > Attach to Process > Attach

You can browse the available service that you are looking for and attach.



回答3:

You should attach Visual Studio to the host process of your web service.

This process is usually the IIS worker process which name is w3wp.exe on IIS 6+ on Windows Server 2003, Vista , later.

To attach to this process, you can use Debug -> Attach to Process in visual studio. Inside the Attach to process dialog box Make sure you've checked the Show processes from all users and also when selected your process, make sure that Managed code is selected. To select managed code click Select... and check the Managed Code checkbox (V2.0 or V4.5,4.0 depends on your selection of framework)



回答4:

You can attach to the process of your web service. In Visual Studio, click menu DebugAttach to process.



回答5:

This writing is 2019, solution is to attach to IISExpress. Debug -> Attach -> find iisExpress (not the tray) in the list, .