title: New HandleProcessCorruptedStateExceptions attribute in .NET 4
body: <p>I'm trying to crash my <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation" rel="nofollow noreferrer">WPF</a> application, and capture the exception using the above new .NET 4 attribute.</p>
  
  <p>I managed to manually crash my application by calling <code>Environment.FailFast("crash");</code>.
  (I also managed to crash it using Hans's code from "<a href="https://stackoverflow.com/questions/2950130/how-to-simulate-a-corrupt-state-exception-in-net-4/2950307#2950307">How to simulate a corrupt state exception in .NET 4?</a>".)</p>
  
  <p>The application calls the above crashing code when pressing on a button.
  Here are my exception handlers:</p>
  
  <pre><code>    protected override void OnStartup(StartupEventArgs e)
      {
          base.OnStartup(e);
  
          AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;
          AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
  
          DispatcherUnhandledException += app_DispatcherUnhandledException;
      }
  
      [HandleProcessCorruptedStateExceptions]
       void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
      {
          //log..
      }
  
      [HandleProcessCorruptedStateExceptions]
       void CurrentDomain_FirstChanceException(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e)
      {
          //log..
      }
  
      [HandleProcessCorruptedStateExceptions]
       void app_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
      {
          //log..
      }
  </code></pre>
  
  <p>The <code>//log...</code> comment shown above is just for illustration; there's real logging code there.</p>
  
  <p>When running in Visual Studio, an exception is thrown, but it doesn't 'bubble' up to those exception handler blocks.
  When running as standalone (without the debugger attached), I don't get any log, despite what I expect.</p>
  
  <p>Why is it so, and how to make the handling code to be executed?</p>