Debugging MVC application in VS2012 attempts to st

2019-01-14 06:01发布

UPDATE

I'm certain this is a Visual Studio bug with no obvious solution. I've encountered a number of people who have the same exact issue. I have submitted a bug ticket with Microsoft here:

http://connect.microsoft.com/VisualStudio/feedback/details/778864/vs2012-is-spawning-two-iisexpress-processes-when-attempting-to-debug

If you are having the same issue as described below, please go vote up the bug ticket so that it gets more attention.


Whenever I attempt to debug an MVC3 (or MVC4) application in Visual Studio 2012 configured to run on IIS express (version 8), I get the following error:

enter image description here

Here's the kicker: IIS Express is starting, even though Visual Studio doesn't think so and the debugger fails to attach. The IIS Express tray opens and I can clearly see all configured websites are started:

enter image description here

Oddly enough, the IIS Express System Tray reports that there were some errors when running IIS Express. Here's what it says:

enter image description here

This is a serious WTF. It's reporting that 8080 is being used by an IIS Express Process - the one that was just started by Visual Studio. So, Visual Studio is attempting to launch IIS twice, and when it predictably fails the second time, the debugger bails. I should note that before launching the debug configuration in Visual Studio, I made absolutely sure no IIS Express processes were already running. I used Process Monitor to verify that Visual Studio is in fact attempting to launch IIS Express twice:

enter image description here

Notice in the screen shot above you can clearly see websites running on IIS Express PID 4732. PID 4924 is the second failed attempt at launching IIS Express.

This issue was initially occurring on a Windows 7 installation. I reformatted completely, installed a fresh copy of VS2012, and got the same issue. I went a step further and reformatted, installed Windows 8 and a fresh copy of VS2012, and the issue persists.

I have created brand new blank MVC3 and MVC4 projects. Nothing fixes it.

I'm tearing out my hair here. Any help would be greatly appreciated.

11条回答
【Aperson】
2楼-- · 2019-01-14 06:22

I ran into an identical issue today (IISExpress trying to start twice and failing when hitting Debug in Visual Studio) while helping another developer with a web forms site. After trying several solutions, we found that we could resolve the problem by:

  • Creating a new, empty Visual Studio solution
  • Adding an "Existing Website" pointing to a new, empty folder
  • Copying the contents of the existing (non-working) website into the new folder we created

Simply removing and re-adding the website to the original solution did not work, nor did creating a new solution and adding back the existing site. I can start IISExpress from the command line just fine.

After doing a before-and-after comparison of the .SLN files I believe that is where the problem lies. Since I had found a workaround I didn't spend a lot of extra time on it. Obviously recreating the entire solution from scratch may not be an option for larger projects (ours was a very small one) but hopefully this at least points in the right direction.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-14 06:24

What worked in my situation was to unload the project, then to edit the csproj file. I removed all sections regarding IIS and IISEXPRESS. Then I reloaded the project and chose USE IIS EXPRESS from the project properties all over again. It then worked.

查看更多
ゆ 、 Hurt°
4楼-- · 2019-01-14 06:25

Right click you MVC project /*all of them one by one*/
go to properties
go to web tab
you must be having having checked "Use local IIS webserver" radio box
in the textbox below it make sure no to projects have the same port which in your case is 8080

查看更多
Melony?
5楼-- · 2019-01-14 06:27

Hi maybe this solutions could help you.

  • Manage RuntimeVersion=”4.0″ to “4.0.30319″

Example:

<applicationPools>
<add name=”Clr4IntegratedAppPool” managedRuntimeVersion=”v4.0.30319″ managedPipelineMode=”Integrated”     CLRConfigFile=”%IIS_USER_HOME%\config\aspnet.config” autoStart=”true” /><br/><br/>

reference:Issue: Visual Studio 2012 > “Unable to launch the IIS Express Web Server”

Under the / element, comment out the line

<add name="HttpLoggingModule" image="%IIS_BIN%\loghttp.dll" />

Under the // element, comment out the line

<add name="HttpLoggingModule" lockItem="true" /> 

After saving your changes try restarting iis express.



reference: from stackoverflow forum: Unable to launch the IIS Express Web server

查看更多
地球回转人心会变
7楼-- · 2019-01-14 06:30

w.Brian, I have followed this post since it's start and have had the exact same problem for quite a while now and I have just discovered what is causing the issue for me. I have been able to reproduce and fix the error for myself with this:

The reason VS2012 is starting iis express twice is related to being attached to a domain and being logged into a domain account. Once I logged into a completely local admin account I was able to launch and debug an MVC4 application without any issues. This is using Windows 8 Pro, VS2012 Update 1, attached to my domain, and no other software/extensions/configuration. Completely clean installation.

查看更多
登录 后发表回答