Catastrophic Failure attaching to IISExpress

2019-06-16 21:21发布

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.

2条回答
叛逆
2楼-- · 2019-06-16 22:02

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 
查看更多
Juvenile、少年°
3楼-- · 2019-06-16 22:19

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.

查看更多
登录 后发表回答