10

I'm having an issue where when I attempt to attach my debugger to IIS express, it fails with a "Unable to attach to the process. Catastrophic failure". It then kills my IIS Express session. I have no clue where to begin debugging this issue.

Steps that lead to this:

  1. My application exists on my local machine
  2. Documents\IISExpress\config\applicationhost.config has the Site set up
  3. I run IIS express via an administrative console mode by going to C:\Program Files\IIS Express\iisexpress.exe
  4. I load up my solution in VS.
  5. I attach attempt to attach my debugger to IIS Express.
  6. I get the catastrophic failure error.
  7. IIS is killed and stopped.

Any idea of where to go for Visual studio logs to see what might have happened? I tried running devenv.exe with the /log option but it did not help with any errors.

I also looked up IIS logs, but nothing out of the ordinary that points to the catastrophic failure.

Patrick McDonald
  • 64,141
  • 14
  • 108
  • 120
Sirpingalot
  • 447
  • 1
  • 5
  • 11
  • look at this https://dzone.com/articles/catastrophic-failure-when say, " Change project settings to enable edit and continue, then press F5 to start the web project in debug mode." – Aristos May 11 '16 at 16:26
  • I tried that out. Still fails. I can't exactly do the same thing (F5) since there are other things that happen when the site is launched. – Sirpingalot May 11 '16 at 16:54

3 Answers3

10

Are you running more than one site within the same application pool? I was having the same problem and believe that separating the app sites into different application pools fixed the issue.

Additionally I had issue when the wrong start-up project was selected in Visual studio. Make sure the correct start-up project is selected before attaching, though I can't see why this should matter.

Also I created a controller for the debugger to be launched from the application, which no only makes it much easier, also appears to have less issues.

    #if DEBUG
    public virtual ActionResult Attach()
    {
        System.Diagnostics.Debugger.Launch();
        return new EmptyResult();
    }
    #endif 
  • 3
    I had the problem where the wrong start-up project was selected. Fixing that removed the Catastrophic Failure for me. – dbruning Jul 14 '16 at 20:42
  • 3
    Fantastic! Looks like the wrong start-up project was the issue. Changing that seemed to resolve the issue for me! :) – Sirpingalot Aug 01 '16 at 20:17
  • 1
    woah, that worked! I didn't believe that Startup Project has anything to do with attaching through "Attach to process", but apparently it does. – Mikl X Feb 06 '18 at 01:17
  • 1
    making the startup project fixed this. Thanks! – Ehsan Sajjad Jun 27 '18 at 16:50
0

From a bit of playing it looks like the problem is attaching to an IISExpress process when:

  • IIS Express is already running via an admin console, and
  • you don't have the relevant IIS Express project(s) nominated as startup projects, and
  • "IIS Express" is configured as the startup server (rather than "External Tool")

If this happens, then for each IIS Express process that is not configured as a startup project:

  • The IISExpress process will be re-launched and the instance running from the admin console will be terminated
  • You will see the "Catastrophic failure" message

You are then able to reattach (after refreshing the process list) to the new IIS Express process at that point.

To avoid this dance, you can either:

  • nominate the IISExpress projects as startup projects, or
  • change the start action to "External Tool".

You are then able to attach to the instances running from your admin console without affecting them.

user834770
  • 88
  • 7
0

Just in case someone is having the same issue, I did see this bizarre behavior when I have set another project as start up project in my application rather than one running on IISExpress processing I am attaching to so simply change your project to start up and Attach to Process.

Dipen Shah
  • 25,562
  • 1
  • 32
  • 58