简体   繁体   English

Visual Studio 2010 - XAML编辑器非常慢

[英]Visual Studio 2010 - XAML Editor Extraordinarily Slow

Has anyone else experience incredibly slow performance in the XAML editor in VS 2010? 有没有其他人在VS 2010的XAML编辑器中体验到令人难以置信的低速性能? If I have a new project with a limited number of files, the performance is fine. 如果我有一个包含有限数量文件的新项目,那么性能很好。 However, if I have a project with a larger number of XAML files, the XAML editor hangs intermittently every few seconds, making it almost impossible to use. 但是,如果我有一个包含大量XAML文件的项目,则XAML编辑器会每隔几秒钟间歇性地挂起,这使得它几乎无法使用。

I should also note that the performance is only slow in one particular project where I am referencing DevExpress 2010. I am not certain if this is related. 我还应该注意,在我引用DevExpress 2010的一个特定项目中,性能只会很慢。我不确定这是否相关。

Any suggestions on solutions to this problem would be greatly appreciated. 任何关于解决这个问题的建议都将不胜感激。

Chris 克里斯

In Visual Studio 2012: 在Visual Studio 2012中:

Go to

Tools > Options > TextEditor > XAML > Misc 

Check Always open documents in XAML view and uncheck Automatically populate toolbox items . 选中Always open documents in XAML view然后取消选中Automatically populate toolbox items

In Visual Studio 2015, 2017: 在Visual Studio 2015中,2017年:

Go to

Tools > Options > XAML Designer 

uncheck Automatically populate toolbox items . 取消选中Automatically populate toolbox items

This fixed my same problem. 这解决了我同样的问题。

If you don't need the visual designer, you can select a different editor in visual studio: 如果您不需要可视化设计器,可以在visual studio中选择其他编辑器:

Right click the xaml file -> Open With... -> Source Code (Text) Editor 右键单击xaml文件 - >打开方式... - >源代码(文本)编辑器

You will only lose the split view, intellisense etc. should still work. 你只会丢失拆分视图,intellisense等应该仍然有效。
If you need to check something in the designer you can still click 'view designer' to open the normal XAML editor again. 如果您需要在设计器中检查某些内容,您仍然可以单击“查看设计器”再次打开常规XAML编辑器。

If you want to improve the performance of the visual designer, try checking DesignerProperties.GetIsInDesignMode in your code-behind. 如果要提高可视化设计DesignerProperties.GetIsInDesignMode的性能,请尝试在代码隐藏中检查DesignerProperties.GetIsInDesignMode The visualiser instantiates your controls to know how to display them, thus executing parts of the code-behind. 可视化器实例化您的控件以了解如何显示它们,从而执行代码隐藏的部分。

Like the OP, I had extreme lag in the xaml editor on a project that relied heavily on DevExpress WPF controls. 和OP一样,我在xaml编辑器中对一个严重依赖DevExpress WPF控件的项目进行了极大的延迟。 After trying unsuccessfully to resolve this issue with the other solutions posted here, I eventually tried deleting my Solution User Options (.suo) file , which is usually located in the same folder as the solution (.sln) file. 在尝试使用此处发布的其他解决方案解决此问题失败后,我最终尝试删除我的解决方案用户选项(.suo)文件 ,该文件通常与解决方案(.sln)文件位于同一文件夹中。 This immediately resolved the issue. 这立即解决了这个问题。 You may want to read this post about what visual studio stores in the suo file so you can reset anything important (such as build configuration - mine always defaults the active solution platform back to "Mixed Platforms" for example) 您可能想阅读这篇文章,了解可视化工作室存储在suo文件中的哪些内容,以便您可以重置任何重要内容(例如构建配置 - 我总是默认将活动解决方案平台恢复为“混合平台”)

Short answer : if you do not use designer much, just replace the default editor for XAML, thus getting rid of XAML visual designer and speeding things up. 简短的回答 :如果你不使用很多设计师,只需替换XAML的默认编辑器,从而摆脱XAML视觉设计师并加快速度。 Right click any XAML file, click Open with... and choose another default editor. 右键单击任何XAML文件,单击打开方式...并选择另一个默认编辑器。 Source code (text) editor works just fine. 源代码(文本)编辑器工作得很好。

Now it should be already fine. 现在应该已经很好了。 If you want to understand the details and completely get rid of the slow designer, read the long answer. 如果你想了解细节并完全摆脱缓慢的设计师,请阅读详细的答案。

Long answer : Here is a nice explanation of what happens and why is it that slow. 答案这里有一个很好的解释,发生了什么,为什么这么慢。

A brief todo based on the aforementioned article in order to completely disable the visual designer of XAML: 基于上述文章的简短todo,以完全禁用XAML的可视化设计器:

  1. Under Tools->Options->Text Editor->XAML->Miscellaneous->Default View check Always open documents in full XAML view 在工具 - >选项 - >文本编辑器 - > XAML->其他 - >默认视图下选中始终在完整XAML视图中打开文档
  2. Open Task manager and end XAML Designer process XDesProc.exe (Note: for VS2013 right click this process and go to containing folder. Rename the exe to sth else, than end the process) 打开任务管理器并结束XAML Designer进程XDesProc.exe(注意:对于VS2013,右键单击此进程并转到包含文件夹。将exe重命名为sth else,而不是结束进程)
  3. Standard XAML editor will load this process again (I guess it will not succeed with VS2013 and actions done in P.2). 标准XAML编辑器将再次加载此进程(我想它不会成功使用VS2013并在P.2中完成操作)。 However, right click any XAML file, Open with... and choose another default editor. 但是,右键单击任何XAML文件,打开方式...并选择另一个默认编辑器。 Source code (text) editor works just fine. 源代码(文本)编辑器工作得很好。

While using dev express, I've noticed some laggy response in the Visual Studio designer. 在使用dev express时,我注意到Visual Studio设计器中存在一些滞后响应。 This appears to be due to the license authentication of the DevExpress products. 这似乎是由于DevExpress产品的许可证认证。

If you delete the " Licenses.Licx " file (found in the project properties folder) you'll notice a marked improvement in performance. 如果删除“ Licenses.Licx ”文件(在项目属性文件夹中找到),您会发现性能有明显改善。

Note: Removing the license file doesn't stop you from using DevExpress controls. 注意:删除许可证文件不会阻止您使用DevExpress控件。 But it does stop VS from constantly authenticating it. 但它确实阻止了VS不断对其进行身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM