asp.net mvc - script - Visual Studio debugging/loading very slow
visual studio debug loading symbols slow (20)
I'm at wits end. Visual Studio is typically painfully slow to debug or just plain load ("start without debugging") 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 slow after that. I could be waiting 1-2 minutes or more.
I'm using Visual Studio 2012 Express, 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.)
I load in Internet Explorer 9 usually, but the same problem happens in Firefox.
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.
The system will load my symbols hundreds 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:
'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.
In the above, I've got three DisplayTemplates: "Contact", "Location", and "StatusCode". It appears that IIS is loading symbols twice for each time the displaytemplate gets called. Thus, if I'm displaying a table of 100 entries that calls all three of these displaytemplates, it's 600 separate symbols loaded.
This isn't a fast operation either. Looking in the log files that IIS generates, it takes about 200 ms for each symbol to load. Thus, super-long delays.
What I've Tried:
- Debug or Release version, it doesn't matter.
- Putting my project on a full IIS implementation on a web server runs it super fast with no problems.
- Cassini, IIS Express 7.5, and IIS Express 8.0 all have the problem.
- Delete All Breakpoints does nothing.
- Clean Solution, or deleting the .suo also do nothing.
- If I repair IIS Express, or delete the
My Docs\IISExpressfolder, or repair/reinstall Visual Studio → the issue MAY go away, but only for a while, before it comes right back.
Any advice at all is appreciated.
To answer more questions, yes my machine definitely has the horsepower. The infuriating thing is that the same project, with NOTHING altered, can load very very quickly sometimes, typically after I repair IIS Express and delete the
My Docs\IISExpress folder. Eventually "something" 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 addons what-so-ever.
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.
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 "loaded symbols" 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:
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'
It looks like Visual Studio is recompiling my displaytemplate every time it's called, which is again, hundreds of times. My theory is that Visual Studio compiles the file, saves it to the network share, the network share then somehow stamps a new time on it, and Visual Studio then thinks the file has changed and thus Visual Studio recompiles it yet again. Only a theory though; I really have no clue.
For one, apparently I have offline files on (this is a desktop computer in an office; I couldn't care less). I'm going to disable, reboot and retry tomorrow.
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.
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 load.
The problem for me was the "Browser Link" feature that is very heavy when you have several tabs open for the same project !
Because every time we launched the project, it opens a new tab with browser link communications.
Just close all tabs associated with the project and keep only one open !
This free instantaneously visual studio ! It’s magic ! ;-)
“Browser Link is a feature since Visual Studio 2013 that creates a communication channel between the development environment and one or more web browsers. You can use Browser Link to refresh your web application in several browsers at once, which is useful for cross-browser testing.”
A quick and easy solution for those who don't have much deviation from default VS settings.
Tools-->Import and Export Settings-->Yes, save my current settings-->Visual C#
I am sure the above solution would work with other default settings too. In my case something messed up with my symbol loading settings but I could not fix it even though I tried quite a few of the suggested solutions.
Do you have enabled FusionLog?
My VisualStudio was very slow to start, open solution and load symbols when start debugging. It was slow only on my machine, but not on other machines.
FusionLog writes tons of log stuff to disk. Just disabling it on RegEdit solved everything, on my case.
This is the FusionLog key on registry:
Check ForceLog value (1 enabled, 0 disabled).
Emptying the symbol cache worked for me.
See: menu bar / Tools / Options / Debugging / Symbols / Empty Symbol Cache
For me, I implemented this tip which basically drastically improved performance by adding the following two attributes to compilation tag in web.config
<compilation ... batch="false" optimizeCompilations="true"> ... </compilation>
What does batch="false" do?
It makes pre-compilation more selective by compiling only pages that have changed and require re-compiling
What exactly is the optimizeCompilations doing? Source
ASP.NET uses a per application hash code which includes the state of a number of things, including the bin and App_Code folder, and global.asax. Whenever an ASP.NET app domain starts, it checks if this hash code has changed from what it previously computed. If it has, then the entire codegen folder (where compiled and shadow copied assemblies live) is wiped out.
When this optimization is turned on (via optimizeCompilations="true"), the hash no longer takes into account bin, App_Code and global.asax. As a result, if those change we don’t wipe out the codegen folder.
Reference: Compilation element on msdn
Go to your environment variables and look for the key _NT_SYMBOL_PATH.
Voila, worked like a charm.
I deleted the "Temporary ASP.NET Files" folder and my localhost page load improved dramatically. Here is the path... %temp%\Temporary ASP.NET Files\
I don't know if you're still having this issue, but I debug sites in Visual Studio by attaching the debugger to the process itself rather than letting VS do it for me and I have found it to greatly improve times. I use an extension for VS called AttachTo and I have a small article on how I use it here.
I hope this helps.
I had execution perfomance troubles with debugging too and i tried very many options of debugger. In my case huge perfomance achieved when i change this options:
Tools - Options - Debugging - Output Window - (General output settings - All debug output) - OFF
I was also facing this issue, below are the steps that I perform and it works for me always:
- Deleting the solution's .suo file.
- Deleting the Temporary ASP.NET Files (You can find it at find it at %WINDOW%\Microsoft.NET\Framework\\Temporary ASP.NET Files)
- Deleting all breakpoints in the application.
If someone notices this behavior coming out of left field, check to make sure you don't have any breakpoints set in web.config. I must have set one with a stray mouse click, and it really slowed down all debug operations.
In my case I noticed that disabling my internet connection would make it run as fast as with ctrl-f5, so I went to debug->options->symbols and just unchecked all .pdb locations.
Seems like VS was trying to connect to these servers every time a debug session was launched.
Note that disabling Debug->Options->Debugging->General "Enable source support" or "Require source files to exactly match the original version" wouldn't make any difference.
In my case it was
Once I unchecked this, my debug start went from 45-60 seconds down to 0-5 seconds.
My slow VS issue was resolved by disabling the Browser Link
None of this worked for me but I found a Breakpoint on a symbol that was deleted. Seems 2010 was hanging on it. To see if this is your issue do debug->windows->breakpoints If any are in there just delete them.
Saunders, mentioned he checked for that but it was not mentioned in the solutions for this problem. Maybe common knowledge for some, but not all of us.
One time, after a power outage, I had to face the same slowness problem each time a breakpoint was hit or a Exception was thrown.
I had the vague remembering that the "suo" file (in the same directory as the "sln" solution file) can be corrupted and make everything slow down.
I deleted my "suo" files and everything was ok. The .suo files deletion is harmless and only implies to recreate my windows layout plus the starting project and a few other non critical customizations.
Open the solution folder in windows explorer, close the visual studio, delete .suo file from windows explorer.
Now open the project in visual studio, hopefully debugger will attached/detached fastly.
The above are all good solutions and I tried all of them, but got the solution here, which is to
Debug -> Delete All Breakpoints
There is also complications in partial views where there is an error on the page that is not recognized immediately. Like Model.SomeValue instead of Model.ThisValue. It might not underline and cause problems in debugging. This can be a real pain to catch.