title: Visual Studio soft-crashing when encountering XAML Errors in initialize
body: <p>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 <code>InitializeComponent()</code> of a control/window.</p>
  
  <p>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 <strong>what</strong> is wrong. Example:</p>
  
  <p><img src="https://i.stack.imgur.com/MW13N.png" alt="alt text"></p>
  
  <p>There is not pop outs, or details <strong>Anywhere</strong> about what is wrong, only a callstack that points to my <code>InitializeComponent()</code> call.</p>
  
  <p>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 <em>completely useless</em> 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).</p>
  
  <p>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.</p>
  
  <p>I have to force-close <code>devenv.exe</code>, 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).</p>
  
  <p><strong>To the point</strong> </p>
  
  <ol>
  <li>Has anyone else experienced this?</li>
  <li>How can I stop studio from locking up.</li>
  <li>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?</li>
  </ol>
  
  <p>Any &amp; All help would be appreciated.</p>
  
  <p>Visual Studio 2010 version: <code>10.0.30319.1RTM</code></p>
  
  <p><strong>Edit &amp; Update</strong></p>
  
  <p>FWIW, mostly the errors that cause this are <code>XamlParseExceptions</code> (I figured this out after i found what was wrong with my XAML). </p>
  
  <p><em>I think I need to be clearer though</em>, Im not looking for the solution to my code problem, as these are usually typos / small things, <strong>I'm looking for a solution to VStudio getting all buggered up as a result.</strong></p>
  
  <p>The particular error in the above image that 100% for sure caused this was a <code>XamlParseException</code> caused by forgetting a <code>Value</code> attribute on a data trigger.</p>
  
  <p>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.</p>
  
  <p><strong>Code that will cause this issue (at least for me)</strong></p>
  
  <p>This is the base template WPF Application, with the following <code>Window.xaml</code> code. The problem is a missing <code>Value="True"</code> on the <code>&lt;DataTrigger ...&gt;</code> in the template. It generates a <code>XamlParseException</code> and Visual Studio Crashes as described above when debugging it.</p>
  
  <pre><code>&lt;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"&gt;
    &lt;Window.Resources&gt;
     &lt;DataTemplate x:Key="BankListItemTemplate"&gt;
      &lt;Border x:Name="ItemBorder" Width="250" Margin="1" BorderBrush="Blue" BorderThickness="5,0,0,0"&gt;
       &lt;Grid&gt;
        &lt;Label Content="{Binding Name}" /&gt;
       &lt;/Grid&gt;
      &lt;/Border&gt;
      &lt;DataTemplate.Triggers&gt;
       &lt;DataTrigger Binding="{Binding IsDirty}"&gt;
        &lt;Setter TargetName="ItemBorder" Property="BorderBrush" Value="Red" /&gt;
       &lt;/DataTrigger&gt;
      &lt;/DataTemplate.Triggers&gt;
     &lt;/DataTemplate&gt;
    &lt;/Window.Resources&gt;
    &lt;Grid&gt;
     &lt;ListView ItemTemplate="{StaticResource BankListItemTemplate}" /&gt;
    &lt;/Grid&gt;
   &lt;/Window&gt;
  </code></pre>
  
  <p><strong>Final Notes</strong></p>
  
  <p>The following solutions <strong>did not</strong> help me:</p>
  
  <ol>
  <li>Restarting Visual Studio</li>
  <li>Rebooting</li>
  <li>Reinstalling Visual Studio</li>
  <li>Disabling add-ins like ReSharper &amp; Reflector</li>
  </ol>
  
  <h2>Update (Way Later) w/ Answer</h2>
  
  <p>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.</p>
  
  <p><strong>The Real Problem:</strong> 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).</p>
  
  <p>Simply turn that off and life will be good again.</p>
  
  <p>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.</p>