Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio regularly freezes running Microsoft.VisualStudio.Web.Host.exe

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.

  • Microsoft.VisualStudio.Web.Host.exe Time Theft
  • Microsoft.VisualStudio.Web.Host.exe
  • Visual Studio 2012 freezes for approximately 30 seconds after every build
like image 884
Sam Avatar asked Sep 30 '14 03:09

Sam


People also ask

Why does Visual Studio hang?

If you experience crashes of Visual Studio, typically when working with a very large solution, your IDE might be out of virtual memory. Typical indicators of the problem include a "one or more errors occurred" message, "the process appears to be deadlocked" message, and OutOfMemory exception in a crash dump.

How do I unfreeze Visual Studio?

The workaround is pretty easy, just follow these simple steps: Open Tools / Options in Visual Studio 2019 and find the Projects and Solutions node. Unselect 'Allow parallel project initialization' Click 'OK' and close the solution.

What is Visualstudio?

Microsoft Visual Studio is an IDE made by Microsoft and used for different types of software development such as computer programs, websites, web apps, web services, and mobile apps. It contains completion tools, compilers, and other features to facilitate the software development process. Try it now.


1 Answers

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.

like image 53
Sam Avatar answered Sep 22 '22 15:09

Sam