且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何调试Web服务,从Web应用程序中的C#.NET解决方案

更新时间:2023-08-31 21:28:22

通常情况下,在Visual Studio调试时所选择的启动项目将在调试模式下执行。你的情况,你需要启动和调试了Web API项目还有WinForms项目。你可以通过在Solution Explorer中右键单击并选择设置启动项目。打开一个对话框,在这里您可以选择多启动项目,然后选择哪些项目开始调试解决方案时。

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.

如何调试Web服务,从Web应用程序中的C#.NET解决方案

另一种选择是有一个启动项目(网络API项目,因为这是为其他项目运行)的要求。然后,您可以在WinForms项目在Solution Explorer中右键单击并选择调试 - > 开始新的实例。你可以这样做多次调试同一项目的多个实例。

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.

显然,你可以在调试器始终连接到任何正在运行的进程,如果你的Web API使用部署IIS会已经在运行。使用Visual Studio上述将连接到正确的工作进程的步骤。

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.