Visual Studio regularly freezes running Microsoft.VisualStudio.Web.Host.exe
Asked Answered
T

5

18

Background

I maintain several web sites that are Visual Studio "Web Site Projects".

Problem

I've found that with a couple of these projects, Visual Studio regularly freezes while I'm working on the code. This doesn't happen for some of the web site projects, and I haven't seen it happen on any Web Application projects.

Symptoms

  • Each time it freezes, it takes about half a minute before I can use it again.
  • During a freeze, Windows Task Manager reports that Microsoft.VisualStudio.Web.Host.exe is maxing out one of the CPU cores.

Steps to Reproduce

  1. Open a .cs file under the App_Code directory.
  2. Make a change to the file.
  3. Save the file.
  4. Navigate somewhere else (eg switch tab, close the file, open different program in Windows).
  5. Navigate back to the file (eg switch tab to it, open it, or go back to Visual Studio).

Other actions that sometimes seem to trigger the problem:

  • "Go to definition"
  • Opening a file
  • Previewing a file
  • Closing a file
  • Using a refactoring
  • "Find usages"

What I've Tried

  • Both Visual Studio 2012 and Visual Studio 2015
  • Changing the website project's build action
  • Disabling "Build Web site as part of solution"
  • Deleting web references and the Bin folder seems to minimise the problem, but obviously this breaks the web site. Maybe web site projects experience this problem when they contain a lot of C# code other than code-behind files?

Similar problems

I found the following potentially-related problems using Google, but none of them seemed to contain a workaround or solution.

Tameka answered 30/9, 2014 at 3:18 Comment(2)
I have the same problem. It usually happens when I switch to another file using Ctrl+Tab or by clicking another tab in VS editor. Help for this will be greatly appreciated.Exceptional
Same. I have a Solution of 50 Web Sites. I use the "Funnel" extension to prevent loading all web sites at once. While this helps reduce the initial loading time. Still VS freezes like you describe. -- I have noticed the difference of saving fils: If I edit two files in different tabs I can switch between them normally while not saving. As soon as I save whichever tab is the current one, Visual Studio will freeze when I try to switch to the other tab.Godfree
T
0

This problem stopped happening when the Web Site project was converted into a Web Application project.

Not an easy solution, but it did stop the problem.

Tameka answered 29/6, 2016 at 1:22 Comment(1)
I've accepted this answer because I feel that it's the most suitable long term workaround for the problem, and most of the other answers either didn't apply or didn't make any difference to the exact situation in the question.Tameka
T
7

I noticed that the problem happened less often when I suspended ReSharper.

ReSharper options in Visual Studio showing the "Suspend Now" button

The problem still happened occasionally when editing classes under App_Code, but restarting Visual Studio worked around it.

Tameka answered 29/6, 2016 at 6:46 Comment(0)
D
6

I was facing a similar problem. A single Web application project with dozens of class libraries, migrated over from VS 2010 into VS 2013.

I was able to solve my problem by disabling the "Hosting Process" option:

To disable the hosting process

  1. Open an executable project in Visual Studio. Projects that do not
    produce executables (for example, class library or service projects) do not have this option.
  2. On the Project menu, click Properties.
  3. Click the Debug tab.
  4. Clear the Enable the Visual Studio hosting process check box.

Full details on MSDN: http://msdn.microsoft.com/en-us/library/ms185330.aspx

Discriminatory answered 18/11, 2014 at 9:6 Comment(7)
@PhilipPittle To be fair, answer is a suggested solution with a link to a how to do what is suggested. If the link dissapears, the suggestion is still valid, assuming its a good suggestion.Steeplejack
@RoggsFolly - Fair point. I updated the answer to include the relevant steps so there's no ambiguity about removing the flag.Pleomorphism
@PhilipPittle Upvoted because the Developer Tools Division at Microsoft needs to move (air quotes) features (end air quotes) like this to "Turn Windows Features on or off". This is just one more feature, like storing hundreds of megabytes of TFS droppings under "$tf", that VS should not be enabling by default.Bouie
I do not have "Debug" tab in my web application project in Visual Studio 2015. Any thoughts how to solve the problem without it?Agentive
Thanks. I get these lock ups while converting a Win Forms app to WPF (both open in their own Visual Studio app) and I try click on any XAML element in the designer. This seems to have fixed that.Plashy
Were you definitely working on a "Web Site Project" or "Web Application Project"? I just tried to find this open for both project types in VS2015, and it wasn't present. The article you linked says it's only applicable for .exe project, whereas I'm not aware of web site/app projects producing .exe files in VS.Tameka
Sorry, by "open", I meant "option".Tameka
B
4

Another option for people experiencing this on old web applications that don't have the properties page in the accepted answer above.

Disable "Allow this precompiled site to be updatable".

  1. Open Site/Solution
  2. Right click and view Property Pages
  3. Go to MSBuild Options
  4. Uncheck "Allow this precompiled site to be updatable"

This worked for me.

Bujumbura answered 20/1, 2016 at 21:16 Comment(2)
Thank you, you fixed my issue. I was unable to debug, save files etc without VS freezing for 10 mins!Sammons
I just tried this in Visual Studio 2015 Update 2, and unfortunately, it didn't seem to make any difference for me.Tameka
T
0

This problem stopped happening when the Web Site project was converted into a Web Application project.

Not an easy solution, but it did stop the problem.

Tameka answered 29/6, 2016 at 1:22 Comment(1)
I've accepted this answer because I feel that it's the most suitable long term workaround for the problem, and most of the other answers either didn't apply or didn't make any difference to the exact situation in the question.Tameka
U
0

They symptoms in the question of this post sound exactly like the nightmares I just had today:

Other actions that sometimes seem to trigger the problem:

"Go to definition"

Opening a file

Previewing a file

Closing a file

Using a refactoring "Find usages"

Plus intellisense wasn't working (even with CTRL + J) and 'Peek definition' was hanging as well.

I had to keep task killing visual studio (both 2015 and 2017).

My fix was to go into the project that I was having problems with, open the 'Package Manager Console' and uninstall and re-install the 'DotNetCompilerPlatform'

uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform 

and then

install-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform

So far every problem I was encountering has not resurfaced (but this was just today so still need to give it time).

UPDATE:

It started creeping back again. I noticed also that whomever had installed to the solution had only done it to two of the various projects. Uninstalling the compiler platform (which means using the compilers that came with Visual Studio) has made life sane again.

Unstep answered 11/8, 2017 at 17:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.