title: Segregating Debug and Release Code in C#
body: <p>I'm writing an application wherein I have some <strong>debug</strong> code that I do not wish to delete, but I wish it to be modified or removed when compiling for release/publish.  For example, I would like something like this in a debug build:</p>
  
  <pre><code>MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  </code></pre>
  
  <p>...to become this in a release build:</p>
  
  <pre><code>MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  </code></pre>
  
  <p>Ideally, I was hoping to do something like this:</p>
  
  <pre><code>#if DEBUG_BUILD
     MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  #else
     MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  #endif
  </code></pre>
  
  <p>I would prefer to not have to add/remove a <em>Conditional Compilation Symbol</em> in the project properties every time I change the build type; it should happen automatically.  Is there a way to do this in Microsoft Visual C# 2008 Express Edition?  Thanks.</p>