Visual Studio在初始化时遇到XAML错误时软崩溃 [英] Visual Studio soft-crashing when encountering XAML Errors in initialize

查看:416
本文介绍了Visual Studio在初始化时遇到XAML错误时软崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Visual Studio 2010的一些严重的问题。当在控件/窗口的 InitializeComponent()中遇到某些类型的XAML错误时,它以特殊的方式崩溃。



程序中断和可视工作室加速,因为它捕获一个异常(因为它是),然后停止在中间显示一个破碎的高亮在我的XAML文件,没有关于什么是错误的细节。示例:





没有弹出,或细节随处有什么问题,只有一个callstack指向我的 InitializeComponent() call。



现在通常我只是做一些尝试和错误来解决这个问题,并找出我在哪里搞砸,但真正的问题是我的代码。此时Visual Studio完全无用。 它报告我的应用程序仍在运行模式。



关闭应用程序并不会停止此行为,关闭视觉工作室让它陷入一个巨大的循环,它大喊我抱怨每个文件打开不是在调试项目,然后重复这个过程,当我已经激活了每个打开的文件。



我必须强制关闭 devenv.exe ,在这之后发生3-4次,这是一个很大的浪费时间(因为我的项目通常是相当大


  1. 我可以在LEAST获得信息吗?
  2. 从这个野兽另一种方式,所以我可以更快地修复我的XAML错误,而不是3-4个试错编译后产生相同的崩溃?

任何&



Visual Studio 2010版本: 10.0.30319.1RTM



编辑&更新



FWIW,大多数原因导致的错误是 XamlParseExceptions 发现我的XAML有什么问题)。



我认为我需要更清楚,我不是寻找解决我的代码问题,因为这些通常是错别字/小事



上面的图片中的特定错误是100%肯定是因为在数据触发器上忘记了 Value 属性而引起的 XamlParseException



我已经修复了这一部分,但是它仍然不能告诉我为什么我的工作室成为一个程序中的一个程序,当一个完全正常的异常抛出XAML的解析。



会导致此问题的代码(至少对我来说)



WPF应用程序,具有以下 Window.xaml 代码。问题是在模板中的< DataTrigger ...> 上缺少 Value =True它会在调试时产生 XamlParseException 和Visual Studio Crashes。

 < Window x:Class =XamlParseExplosion.MainWindow
xmlns =http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x =http: //schemas.microsoft.com/winfx/2006/xaml
Title =MainWindowHeight =350Width =525>
< Window.Resources>
< DataTemplate x:Key =BankListItemTemplate>
< Border x:Name =ItemBorderWidth =250Margin =1BorderBrush =BlueBorderThickness =5,0,0,0>
< Grid>
< Label Content ={Binding Name}/>
< / Grid>
< / Border>
< DataTemplate.Triggers>
< DataTrigger Binding ={Binding IsDirty}>
< Setter TargetName =ItemBorderProperty =BorderBrushValue =Red/>
< / DataTrigger>
< /DataTemplate.Triggers>
< / DataTemplate>
< /Window.Resources>
< Grid>
< ListView ItemTemplate ={StaticResource BankListItemTemplate}/>
< / Grid>
< / Window>

最终注释



以下解决方案没有帮助我:


  1. 重新启动Visual Studio

  2. 重新启动

  3. 重新安装Visual Studio

  4. 停用像ReSharper&反射器



更新(稍后更新)w / Answer



添加到这里(作为一个伪回答),因为我发现更多的信息关于这个,我想传递给在谷歌的人找到这个问题。



真正的问题:在Debug - >异常中选择XamlParseException当它发生时中断,因为这发生在WPF wireup vstudio无法正确捕获它(通常它会下降几个级别,并在那里处理vstudio可以处理它。)



只要关闭它,生活就会再次好起来。



想把这个作为一个答案,因为mazelo提供的答案也是正确的,当vstudio作为管理员运行似乎能够捕获异常并从那里调试,所以我不想夺走他的回答状态,因为他的解决方案可以工作。

解决方案

我有一个类似的问题。下班后我有想法开始视觉工作室作为管理员。修正了问题,但仍然不知道为什么。


I've been having some serious issues with Visual Studio 2010 as of late. It's been crashing in a peculiar way when I encounter certain types of XAML errors during the InitializeComponent() of a control/window.

The program breaks and visual studio gears up like it's catching an exception (because it is) and then stops midway displaying a broken highlight in my XAML file with no details as to what is wrong. Example:

There is not pop outs, or details Anywhere about what is wrong, only a callstack that points to my InitializeComponent() call.

Now normally I'd just do some trial and error to fix this problem, and find out where i messed up, but the real problem isn't my code. Visual Studio is rendered completely useless at this point. It reports my application still in "Running" mode. The Stop/Break/Restart buttons on the toolbar or in the menus don't do anything (but grey out).

Closing the application does not stop this behaviour, closing visual studio gets it stuck in a massive loop where it yells at me complaining every file open is not in the debug project, then repeats this process when i have exausted every open file.

I have to force-close devenv.exe, and after this happening 3-4 times in a row it's a lot of wasted time (as my projects are usually pretty big and studio can be quite slow @ loading).

To the point

  1. Has anyone else experienced this?
  2. How can I stop studio from locking up.
  3. Can I at LEAST get information out of this beast another way so i can fix my XAML error sooner rather than after 3-4 trial-and-error compiles yielding the same crash?

Any & All help would be appreciated.

Visual Studio 2010 version: 10.0.30319.1RTM

Edit & Update

FWIW, mostly the errors that cause this are XamlParseExceptions (I figured this out after i found what was wrong with my XAML).

I think I need to be clearer though, Im not looking for the solution to my code problem, as these are usually typos / small things, I'm looking for a solution to VStudio getting all buggered up as a result.

The particular error in the above image that 100% for sure caused this was a XamlParseException caused by forgetting a Value attribute on a data trigger.

I've fixed that part but it still doesn't tell my why my studio becomes a lump of neutered program when a perfectly normal exception is thrown in the parsing of the XAML.

Code that will cause this issue (at least for me)

This is the base template WPF Application, with the following Window.xaml code. The problem is a missing Value="True" on the <DataTrigger ...> in the template. It generates a XamlParseException and Visual Studio Crashes as described above when debugging it.

<Window x:Class="XamlParseExplosion.MainWindow"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   Title="MainWindow" Height="350" Width="525">
  <Window.Resources>
   <DataTemplate x:Key="BankListItemTemplate">
    <Border x:Name="ItemBorder" Width="250" Margin="1" BorderBrush="Blue" BorderThickness="5,0,0,0">
     <Grid>
      <Label Content="{Binding Name}" />
     </Grid>
    </Border>
    <DataTemplate.Triggers>
     <DataTrigger Binding="{Binding IsDirty}">
      <Setter TargetName="ItemBorder" Property="BorderBrush" Value="Red" />
     </DataTrigger>
    </DataTemplate.Triggers>
   </DataTemplate>
  </Window.Resources>
  <Grid>
   <ListView ItemTemplate="{StaticResource BankListItemTemplate}" />
  </Grid>
 </Window>

Final Notes

The following solutions did not help me:

  1. Restarting Visual Studio
  2. Rebooting
  3. Reinstalling Visual Studio
  4. Disabling add-ins like ReSharper & Reflector

Update (Way Later) w/ Answer

I want to add to this (as a pseudo answer) because I found out more information about this later that I want to pass along to people finding this question in google.

The Real Problem: XamlParseException was selected in Debug -> Exceptions to break when it occurs, because this happens during the WPF wireup vstudio cannot catch it correctly (normally it would fall down a couple more levels and be handled there where vstudio could handle it).

Simply turn that off and life will be good again.

I didn't want to put this as an answer because the answer provided by mazelo was correct too, when vstudio is run as Administrator it seems to be able to catch the exception properly and debug from there so I didn't want to take away his answered status because his solution does work.

解决方案

I had a similar problem. After hours i had the idea to start visual studio as admin. Fixed the problem, but still don't know why.

这篇关于Visual Studio在初始化时遇到XAML错误时软崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆