title: c# force debug mode programmatically
body: <p>Nevermind why one might want to do this, I'm just curious to know if it can be done.</p>
  
  <p>Here's my code that doesn't work:</p>
  
  <pre><code>if (!Debugger.IsAttached)
  {
      try
      {
          Debugger.Launch();
          while (!Debugger.IsAttached)
          {
              Thread.Sleep(1000);
          }
      }
      catch (System.Security.SecurityException e)
      {
          Console.WriteLine("exception " + e.Message);
      }
  }
  </code></pre>
  
  <p>Basically I was curious to know how to use the <code>Debugger.Launch()</code> method.</p>