Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What process must I attach to for debugging an MVC 6 wep app using the IIS Express profile?

I am desperately trying to achieve the supposedly very simple goal of debugging an MVC 6 (Core 1.1) web app in VS 2017 RC3. Normal debugging does not work, as VS always times out trying to attach to the program, as asked about in my VS 2017 always times out debugging an MVC Core website on IIS Express profile question. Now I am stuck with "Start without debugging", and trying to attach to whatever process is actually hosting my app.

The app type is a Console Application, which starts up the Kestrel host, yet this console app produces no .exe that I can find anywhere. Of course I have tried to attach to IIS Express, but using that, none of my breakpoints are ever hit. I believe in these scenarios, IIS EXpress merely acts as a proxy to the actual console app that is my MVC app, so maybe I should attach to the actual web app process, but what in hell's name is that process?

like image 811
ProfK Avatar asked Dec 18 '22 09:12

ProfK


1 Answers

You need to attach to the dotnet.exe process. You may have multiple dotnet.exe (especially if you run a .NET Core project VS at the same time). Typically, when you press Ctrl+Shift+P in VS it would be the first dotnet.exe.

However, your symptoms look like your application is not actually starting at all and IIS Express cannot find the process. I would start from checking event log for IIS Express related events as IIS logs the process ID of the application it started and the failures if any.

A better way to debug this might be to skip IIS Express at all and start your application directly from command line with dotnet run. This way you will see output in the command line window. You can also print the process id from your Main method with:

Console.WriteLine("Process ID: " + System.Diagnostics.Process.GetCurrentProcess().Id);

so that it easy to figure out what process to attach to if you need it.

like image 136
Pawel Avatar answered Dec 26 '22 07:12

Pawel