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

2019-06-16 08:02发布

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?

5条回答
疯言疯语
2楼-- · 2019-06-16 08:19

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)

查看更多
该账号已被封号
3楼-- · 2019-06-16 08:22

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

查看更多
Deceive 欺骗
4楼-- · 2019-06-16 08:27

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

查看更多
劳资没心,怎么记你
5楼-- · 2019-06-16 08:32

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.

查看更多
兄弟一词,经得起流年.
6楼-- · 2019-06-16 08:36

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.

查看更多
登录 后发表回答