title: Visual Studio debugging/loading very slow
body: <p>I'm at wit's end. Visual Studio is <em>typically</em> painfully slow to debug or just plain load (&quot;start without debugging&quot;) my ASP.NET MVC sites. Not always: at first, the projects will load nice and fast, but once they load slow, they'll always load slowly after that. I could be waiting 1-2 minutes or more.</p>
  <p><strong>My setup:</strong></p>
  <p>I'm using <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express" rel="noreferrer">Visual Studio 2012 Express</a>, currently, but I've had the same problem in Visual Studio 2010 Express as well. My solution is stored on a network drive; specifically, it's My Documents redirected to a network drive, if it matters. (It shouldn't. There are times where my site loads very fast under this setup.)</p>
  <p>I load in Internet  Explorer 9 usually, but the same problem happens in Firefox.</p>
  <p>This can happen in any ASP.NET MVC project I work on, and it seems to revolve around having DisplayTemplates, which all my ASP.NET MVC projects do. And it's all C# and Razor if that mattered.</p>
  <h3>Symptoms:</h3>
  <p>The system will load my symbols <em>hundreds</em> of times. Basically, the following, but there are at least 300 such rows, each with ever-so-slightly different DLL files for the same CSHTMLs:</p>
  <pre><code>'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_contact.cshtml.22013bb9.xighmhow.dll', Symbols loaded.
  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_contact.cshtml.22013bb9.cv5hktkf.dll', Symbols loaded.
  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.1o77hs8i.dll', Symbols loaded.
  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.jja-77mw.dll', Symbols loaded.
  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_location.cshtml.22013bb9.l_e9ev_s.dll', Symbols loaded.
  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_location.cshtml.22013bb9.b4n59gom.dll', Symbols loaded.
  </code></pre>
  <p>In the above, I've got three DisplayTemplates: &quot;Contact&quot;, &quot;Location&quot;, and &quot;StatusCode&quot;. It appears that IIS is loading symbols twice for each time the display template gets called. Thus, if I'm displaying a table of 100 entries that call all three of these display templates, it's 600 separate symbols loaded.</p>
  <p>This isn't a fast operation either. The log files that IIS generates take about 200  ms for each symbol to load. Thus, super-long delays.</p>
  <p><strong>What I've Tried:</strong></p>
  <ul>
  <li>Debug or Release version, it doesn't matter.</li>
  <li>Putting my project on a full IIS implementation on a web server runs it super fast with no problems.</li>
  <li>Cassini, IIS  Express 7.5, and IIS  Express 8.0 all have the problem.</li>
  <li><strong>Delete All Breakpoints does nothing.</strong></li>
  <li><em>Clean Solution</em>, or deleting the .suo also do nothing.</li>
  <li>If I repair IIS  Express/ delete the <code>My Docs\IISExpress</code> folder, or repair/reinstall Visual Studio → the issue MAY go away, but only for a while before it comes right back.</li>
  </ul>
  <p>Any advice at all is appreciated.</p>
  <p>To answer more questions, yes my machine definitely has horsepower. The infuriating thing is that the same project, with NOTHING altered, can sometimes load very quickly, typically after I repair IIS  Express and delete the <code>My Docs\IISExpress</code> folder. Eventually, &quot;something&quot; happens and it's down to 2 minutes to load again. What I'm working on is not a complicated project. No external libraries or dependencies and my VS.NET has no add-ons whatsoever.</p>
  <p>Of note, this machine has Symantec Endpoint Protection, which has a history of causing havoc. But disabling it outright (it's good to be an administrator) did not fix the problem.</p>
  <p>I have a theory at this point. I'm thinking this is all because I'm working off a redirected folder off a network share. While the debugger was going through its hundreds of &quot;loaded symbols&quot; lines, I paused to see what it was doing. It was in my code, loading the DisplayTemplate I had. Stepping into the template output this:</p>
  <pre><code>Step into: Stepping over non-user code 'System.Threading.WaitHandle.InternalWaitOne'
  Step into: Stepping over non-user code 'System.Threading.WaitHandle.WaitOne'
  Step into: Stepping over non-user code 'System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated'
  Step into: Stepping over non-user code 'System.CodeDom.Compiler.Executor.ExecWaitWithCapture'
  Step into: Stepping over non-user code 'Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch'
  Step into: Stepping over non-user code 'Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch'
  Step into: Stepping over non-user code 'System.Web.Compilation.AssemblyBuilder.Compile'
  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.bciuyg14.dll', Symbols loaded.
  Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.CompileWebFile'
  Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.GetVPathBuildResultInternal'
  Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert'
  Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory'
  Step into: Stepping over non-user code 'System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists'
  Step into: Stepping over non-user code 'System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName'
  Step into: Stepping over non-user code 'System.Web.Mvc.VirtualPathProviderViewEngine.FindPartialView'
  Step into: Stepping over non-user code 'System.Web.Mvc.ViewEngineCollection.Find'
  Step into: Stepping over non-user code 'System.Web.Mvc.ViewEngineCollection.FindPartialView'
  Step into: Stepping over non-user code 'System.Web.Mvc.Html.TemplateHelpers.ActionCacheViewItem.Execute'
  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.kwj3uqan.dll', Symbols loaded.
  Step into: Stepping over non-user code 'System.RuntimeType.CreateInstanceSlow'
  Step into: Stepping over non-user code 'System.Web.Mvc.DependencyResolver.DefaultDependencyResolver.GetService'
  Step into: Stepping over non-user code 'System.Web.Mvc.BuildManagerViewEngine.DefaultViewPageActivator.Create'
  Step into: Stepping over non-user code 'System.Web.Mvc.BuildManagerCompiledView.Render'
  </code></pre>
  <p>It looks like Visual Studio is recompiling my display template <strong>every time</strong> it's called, which is again, hundreds of times. My theory is that Visual Studio compiles the file, saves it to the network share, then somehow stamps a new time on it, and Visual Studio then thinks the file has changed. Thus, Visual Studio recompiles it yet again. Only a theory though; I really have no clue.</p>
  <p>For one, apparently, I have offline files (this is a desktop computer in an office; I couldn't care less). I'm going to disable, reboot, and retry tomorrow.</p>
  <p>Plus, moving my project, as is, to the local C: fixes it. It loads very quickly. But this is not ideal in a work environment. I lose Previous Versions, my code isn't backed up at all unless I manually copy it, and it's no longer shared with anyone.</p>
  <p>I can make do with copying it back and forth from C to the network share if it comes to it. It's much more annoying to wait two minutes for every page to load.</p>