title: Debug.WriteLine() is not hit
body: <p>I am debugging a Windows service (by hitting <code>F5</code> in Visual&nbsp;Studio&nbsp;2010) using the following code:</p>
  
  <p>In <em>Program.cs</em> file:</p>
  
  <pre><code>static void Main() {
  
      if (!Environment.UserInteractive) {
          // We are not in debug mode, startup as service
  
          ServiceBase[] ServicesToRun;
          ServicesToRun = new ServiceBase[] { new MyServer() };
          ServiceBase.Run(ServicesToRun);
      } 
      else {
          // We are in debug mode, startup as application
  
          MyServer service = new MyServer();
          service.StartService();
          System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
      }
  }
  </code></pre>
  
  <p>And in <em>MyServer.cs</em> file:</p>
  
  <pre><code>public void StartService() {
      this.OnStart(new string[0]);
  }
  </code></pre>
  
  <p>In the past, I used the <code>Debug.WriteLine("xxx")</code> line without any problem in all my service code, but now I noticed that all <code>Debug.WriteLine()</code> lines are not called anymore.</p>
  
  <p>I clearly see that the debugger is jumping over these lines when I debug with <em>Step Into</em> (<code>F11</code>) - (thus, there is no output text on the output Window), whereas the service is correctly started in <em>"debug mode"</em>.</p>
  
  <p>I don't understand why the <code>Debug</code> code won't be called. Suggestions?</p>
  
  <p>I build my solution in debug mode (<code>Define DEBUG constant</code> is checked), but I noticed that the code surrounded by <code>#if DEBUG ... #endif</code> is not called. That is weird...</p>