title: Why is my Catch block only running while Debugging in Visual Studio?
body: <p>Code in Program.cs</p>
  
  <pre><code>[STAThread]
  static void Main()
  {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
  
      try
      {
          Application.Run(new Form1());
      }
      catch (Exception ex)
      {
          MessageBox.Show("Blah...");
      }
  }
  </code></pre>
  
  <p>In Form1 I have a button with the code <code>throw new Exception("");</code>.</p>
  
  <p>If I run the application from Visual Studio, then my messagebox pops up (with message 'Blah...'). But if I run the application from executable file, then the catch block doesn't execute at all.</p>
  
  <p>Why the difference?</p>
  
  <p>I am using Visual Studio 2010, .NET 4.0, Windows XP.</p>