本文翻译自:Visual Studio debugging/loading very slow

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. Visual Studio 通常很难调试,或者只是简单地加载(“启动而不调试”)我的ASP.NET MVC站点。 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. 我可以等待1-2分钟或更长时间。

My setup: 我的设置:

I'm using Visual Studio 2012 Express , currently, but I've had the same problem in Visual Studio 2010 Express as well. 我目前正在使用Visual Studio 2012 Express ,但我在Visual Studio 2010 Express中也遇到了同样的问题。 My solution is stored on a network drive; 我的解决方案存储在网络驱动器上; specifically, it's My Documents redirected to a network drive, if it matters. 具体来说,如果重要的话,它的My Documents会重定向到网络驱动器。 (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. 我通常在Internet Explorer 9中加载,但在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. 这可能发生在我工作的任何ASP.NET MVC项目中,它似乎围绕着DisplayTemplates,我的所有ASP.NET MVC项目都是这样做的。 And it's all C# and Razor, if that mattered. 而这一切都是C#和Razor,如果重要的话。

Symptoms: 症状:

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: 基本上,以下,但至少有300个这样的行,每个行对于相同的CSHTML,每个都有不同的DLL文件:

'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". 在上面,我有三个DisplayTemplates:“Contact”,“Location”和“StatusCode”。 It appears that IIS is loading symbols twice for each time the displaytemplate gets called. 似乎IIS每次调用displaytemplate时都会加载符号两次。 Thus, if I'm displaying a table of 100 entries that calls all three of these displaytemplates, it's 600 separate symbols loaded. 因此,如果我显示一个包含100个条目的表,这些条目调用所有这三个displaytemplate,则加载600个单独的符号。

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. 查看IIS生成的日志文件,每个符号加载大约需要200毫秒。 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. 将我的项目放在Web服务器上的完整IIS实现上可以非常快速地运行它,没有任何问题。
  • Cassini, IIS Express 7.5, and IIS Express 8.0 all have the problem. Cassini,IIS Express 7.5和IIS Express 8.0都有问题。
  • Delete All Breakpoints does nothing. 删除所有断点不执行任何操作。
  • Clean Solution , or deleting the .suo also do nothing. 清理解决方案 ,或删除.suo也什么都不做。
  • If I repair IIS Express, or delete the My Docs\\IISExpress folder, or repair/reinstall Visual Studio → the issue MAY go away, but only for a while, before it comes right back. 如果我修复IIS Express,或删除My Docs\\IISExpress文件夹,或者修复/重新安装Visual Studio→问题可能会消失,但只有一段时间后才能恢复。

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. 令人气愤的是,同样的项目,有任何改变,有时可以非常快地加载,通常是在我修复IIS Express并删除My Docs\\IISExpress文件夹之后。 Eventually "something" happens and it's down to 2 minutes to load again. 最终会发生“某事”,再次加载需要2分钟。 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. 没有外部库或依赖项,我的VS.NET没有任何附加组件。

Of note, this machine has Symantec Endpoint Protection, which has a history of causing havoc. 值得注意的是,该机器具有Symantec Endpoint Protection,它具有造成严重破坏的历史。 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. 这是在我的代码中,加载我有的DisplayTemplate。 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. 看起来Visual Studio 每次调用时都会重新编译我的displaytemplate,这也是数百次。 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. 我的理论是Visual Studio编译文件,将其保存到网络共享,网络共享然后以某种方式在其上标记新的时间,然后Visual Studio认为文件已更改,因此Visual Studio再次重新编译它。 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. 另外,将我的项目按原样移动到本地C:修复它。 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. 如果涉及它,我可以将它从C来回复制到网络共享。 It's much more annoying to wait two minutes for every page load. 每个页面加载等待两分钟会更烦人。


#1楼

参考:https://stackoom.com/question/qjVQ/Visual-Studio调试-加载速度很慢


#2楼

I think I may finally at least know the cause, though not the reason why. 我想我最终可能至少知道原因,但不是原因。 When the problem started occurring again, I noticed a ton of "conhost.exe" processes orphaned. 当问题再次出现时,我注意到大量的“conhost.exe”进程孤立了。 I would close Visual Studio and they would remain open. 我会关闭Visual Studio,它们会保持开放状态。 Ending task on each of them has finally, reliably solved the problem. 他们每个人的结束任务终于可靠地解决了这个问题。 [hopefully] [希望]

(Just note, conhost.exe isn't a Visual Studio process though Visual Studio uses it. Thus, other users out there may have other applications out there that run conhost.exe. I know my machine doesn't which is why I can safely end task all of them but YMMV.) (请注意,虽然Visual Studio使用它,但conhost.exe不是Visual Studio进程。因此,其他用户可能还有其他运行conhost.exe的应用程序。我知道我的机器不是我可以的原因安全地结束所有这些任务,但YMMV。)

As to why this happens? 至于为什么会这样? It seems to occur when I open more than one project at once, which I tend to do often, even though I only build and debug one of them at any time. 这似乎发生在我同时打开多个项目时,我倾向于经常这样做,即使我只是随时构建和调试其中一个项目。


Edit #1 - This isn't a "silver bullet" unfortunately. 编辑#1 - 不幸的是,这不是一个“银弹”。 It doesn't always work for me. 它并不总是对我有用。 Typically, when things get slow, I just close all of my Visual Studio sessions, then go into the task manager and end any instance of it, conhost.exe, iisexpress.exe Microsoft.VisualStudio.Web.Host.exe and MSBuild.exe I can find. 通常,当事情变慢时,我只关闭所有Visual Studio会话,然后进入任务管理器并结束它的任何实例,conhost.exe,iisexpress.exe Microsoft.VisualStudio.Web.Host.exe和MSBuild.exe我可以找到。

Typically, after that, when I restart my project it'll then load quickly. 通常,在那之后,当我重新启动我的项目时,它会快速加载。 But not always. 但不总是。

Really I think the best course of action is probably to not build & debug code off a redirected folder/network share. 真的,我认为最好的做法可能是不在重定向的文件夹/网络共享上构建和调试代码。


Edit #2 - Two years later, and this is still an issue for me in Visual Studio Community 2013, but I did seem to at least find the culprit task: Explorer.exe . 编辑#2 - 两年后,在Visual Studio社区2013中,这仍然是一个问题,但我似乎至少找到了罪魁祸首任务: Explorer.exe Yeah, who knew. 是的,谁知道。 The moment I end that task, bam, page loads in a single second. 我结束那个任务的那一刻,bam,页面加载一秒钟。

If I have a Windows Explorer file browser open to my redirected network drive (which is often since that's where my code is), this problem seems to occur. 如果我有一个Windows资源管理器文件浏览器打开我的重定向网络驱动器(这通常是我的代码所在的位置),似乎会出现此问题。 Closing the window isn't enough, I have to kill the whole Explorer.exe task. 关闭窗口是不够的,我必须杀死整个Explorer.exe任务。 I could only guess what it's doing...going nuts with file handles? 我只能猜到它在做什么......用文件句柄搞定?

I can usually use the task manager to start up a new explorer.exe task (I can only take so much alt-tabbing), and Visual Studio will continue to load nice and quick. 我通常可以使用任务管理器来启动一个新的explorer.exe任务(我只能采取这么多alt-tabbing),并且Visual Studio将继续加载漂亮和快速。 But if I so much as open Windows Explorer again, it almost always goes back to super-slow-mo. 但是,如果我再次打开Windows资源管理器,它几乎总是回到超慢速。

So, if you've got a redirected network share, give it a shot. 因此,如果您有重定向的网络共享,请试一试。 It sure beats working locally. 它肯定胜过当地的工作。


#3楼

I had problems with slow Visual Studio debugging when "Native Code" debugger was enabled. 启用“Native Code”调试器时,我遇到了Visual Studio调试速度慢的问题。 Try disabling it. 尝试禁用它。

On "Visual Studio 2012" go to: 在“Visual Studio 2012”上转到:

  1. Project Properties -> 项目属性 - >
  2. Web -> 网 - >
  3. Debuggers (bottom of page). 调试器(页面底部)。 -> - >
  4. Disable all except ASP.NET 禁用除ASP.NET以外的所有

Hope it helps. 希望能帮助到你。

Similar questions: 1 , 2 类似的问题: 1 , 2


#4楼

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. 在我的情况下,我注意到禁用我的互联网连接将使其运行速度与ctrl-f5一样快,所以我去调试 - >选项 - >符号,只是取消选中所有.pdb位置。

Seems like VS was trying to connect to these servers every time a debug session was launched. 似乎VS每次启动调试会话时都试图连接到这些服务器。

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. 请注意,禁用Debug-> Options-> Debugging-> General“启用源支持”或“要求源文件与原始版本完全匹配” 不会有任何区别。


#5楼

Here is how I solved the "slow symbol loading" problem in Visual Studio 2012: 以下是我在Visual Studio 2012中解决“慢符号加载”问题的方法:

  • Go to Tools -> Options -> Debugging -> General 转到工具 - >选项 - >调试 - >常规

  • CHECK the checkmark next to "Enable Just My Code". 选中“启用我的代码”旁边的复选标记。

  • Go to Tools -> Options -> Debugging -> Symbols 转到工具 - >选项 - >调试 - >符号

  • Click on the "..." button and create/select a new folder somewhere on your local computer to store cached symbols. 单击“...”按钮,在本地计算机上的某处创建/选择一个新文件夹以存储缓存的符号。 I named mine "Symbol caching" and put it in Documents -> Visual Studio 2012. 我将其命名为“符号缓存”并将其放在Documents - > Visual Studio 2012中。

  • Click on "Load all symbols" and wait for the symbols to be downloaded from Microsoft's servers, which may take a while. 单击“加载所有符号”并等待从Microsoft的服务器下载符号,这可能需要一段时间。 Note that Load all symbols button is only available while debugging. 请注意,“加载所有符号”按钮仅在调试时可用。

  • UNCHECK the checkmark next to "Microsoft Symbol Servers" to prevent Visual Studio from remotely querying the Microsoft servers. 取消勾选“Microsoft Symbol Servers”旁边的复选标记,以防止Visual Studio远程查询Microsoft服务器。

  • Click "OK". 单击“确定”。

From now on, symbol loading should be much faster. 从现在开始,符号加载应该快得多。

Note that if you make any changes/downloads to Microsoft assemblies, you may need to go back into the Symbols dialog box and "Load all symbols" again. 请注意,如果对Microsoft程序集进行任何更改/下载,则可能需要再次返回“符号”对话框和“加载所有符号”。


#6楼

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. 我不知道你是否还有这个问题,但是我通过将调试器附加到进程本身来调试Visual Studio中的站点,而不是让VS为我做这些,我发现它可以大大缩短时间。 I use an extension for VS called AttachTo and I have a small article on how I use it here . 我使用VS的扩展名为AttachTo,我在这里有一篇关于如何使用它的小文章。

I hope this helps. 我希望这有帮助。

Visual Studio调试/加载速度很慢相关推荐

  1. Pytorch采坑记录:每隔num_workers个iteration数据加载速度很慢

      最近在做某个视觉任务的模型训练,由于数据量比较少为了效果好一点,决定现在imagenet上pretrain一下骨干网络.但是在训练的时候遇到了一个问题:每隔num_workers个iteratio ...

  2. 华为防火墙配置了限制一台主机只能访问固定域名和IP的安全策略后打开网站加载速度很慢半天打不开

    环景: 华为USG6311E VRP ® Software, Version 5.170 (USG6300E V600R007C00SPC200) V200R007C00SPC091 PC联想win1 ...

  3. Google浏览器限制网速调试加载速度

    问题 项目中,我们测试的时候有时需要限制网速,来看各种情况下的加载感受. 解决办法 Google浏览器 F12 打开开发者工具. Network面板可以设置网络的通信方式. 默认正常模式.这里可以设置 ...

  4. vue首屏加载速度慢_Vue首屏加载速度优化如何提升80%?本文详解

    在Vue项目中,引入到工程中的所有js.css文件,编译时都会被打包进vendor.js,浏览器在加载该文件之后才能开始显示首屏.若是引入的库众多,那么vendor.js文件体积将会相当的大,影响首屏 ...

  5. Vue首屏加载速度优化,提升80%以上

    在Vue项目中,引入到工程中的所有js.css文件,编译时都会被打包进vendor.js,浏览器在加载该文件之后才能开始显示首屏.若是引入的库众多,那么vendor.js文件体积将会相当的大,影响首屏 ...

  6. Vue首屏加载速度优化,我用这几个技巧提升80%以上

    作者:谁动了我的橘子 原文链接:https://juejin.im/post/5edf5b22e51d4578975a7024 在Vue项目中,引入到工程中的所有js.css文件,编译时都会被打包进v ...

  7. vue 关闭 窗口后清除所有数据_Vue首屏加载速度优化,我用这几个技巧提升80%以上...

    前端潮咖 点击上面蓝字,关注我们! 关注 关注前端潮咖,每日精选好文 作者:谁动了我的橘子 来源:https://juejin.im/post/5edf5b22e51d4578975a7024 在Vu ...

  8. 【前端开发】25种提高网页加载速度的方法和技巧

    尊重原创:http://blog.csdn.net/wxzking/article/details/4089384 您希望加快网页的加载速度吗?了解如何通过缩短加载时间来改善拨号上网用户的浏览体验,在 ...

  9. 网站加载速度影响因素以及如何增强

    网站打开速度是用户体验和 SEO 营销的要点之一.许多研究已经证明,当网页加载时间超过 3 秒,超过 50% 的用户会关闭网页.网站打开过慢会造成负面用户体验,增加跳出率,导致你的网站在搜索结果页的位 ...

最新文章

  1. java读取数据,2,2,1方式读取
  2. Android 使用自带的HttpClient进行https请求出现403的解决过程记录
  3. Android中通过数组资源文件xml与适配器两种方式给ListView列表视图设置数据源
  4. java instraction_Java Instruction.getCodeUnits方法代码示例
  5. 花椒web端实时互动流媒体播放器
  6. 服务发现技术是如何演进出来的?
  7. 编写高性能 .NET 代码 第二章:垃圾回收
  8. python编写ATM类_Python中编写类的各种技巧和方法
  9. [转]Spring注解-@Configuration注解、@Bean注解以及配置自动扫描、bean作用域
  10. Ruby游戏开发-BMXP介绍
  11. python网络爬虫系列教程——PhantomJS包应用全解
  12. appenders_Log4j Appenders教程
  13. 使用WIN32汇编语言实现一个基本windows窗口的过程分析
  14. 图元变形lisp源码_CAD lisp 实用小程序(源代码)
  15. 论文解读《TS-m6A-DL:使用通用深度学习模型对n6-甲基腺苷位点进行组织特异性识别》
  16. 海洋cms常见问题有哪些?
  17. 图片的高频与低频分量 初识 与 相关博客
  18. 服务器的噪音会影响听力吗,噪声对听力的三大影响
  19. keystone中Vertify operation出现:No handlers could be found for logger keystoneclient.httpclient的问题
  20. 当北京爷们遭遇上海男人

热门文章

  1. 【Android游戏开发十五】关于Android 游戏开发中 OnTouchEvent() 触屏事件的性能优化笔记! .
  2. 世界应该多点理解关爱,少点争吵
  3. 算法---------数组-----------翻转单链表
  4. 高大上的Android沉浸式状态栏?
  5. 第四周项目二-太乐了
  6. 近20个绚丽实用的jQuery/CSS3侧边栏菜单
  7. LeetCode 4 两个排序数组的中位数
  8. iOS架构-cocoapods打包静态库(依赖私有库、开源库、私有库又包含静态库)(14)
  9. (022)java后台开发之HttpServletRequest
  10. 阿里面试题,为什么wait()方法要放在同步块中?