Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 781
Harshit Solanki Avatar asked Jul 28 '14 10:07

Harshit Solanki


1 Answers

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.

Solution Property Pages

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.

like image 103
Martin Liversage Avatar answered Sep 27 '22 17:09

Martin Liversage