title: Debugging a Windows Console Application from Task Scheduler
body: <p>I also checked previous questions on Stack Overflow before posting this.</p>
  
  <p>Here is my problem:</p>
  
  <p>I created a Windows Console Application on Visual Studio 2017. This application is supposed to fetch some data from tables and send email at regular intervals. Initially, I created a Windows Service and it is working fine but later I decided to execute this from Task Scheduler as changing schedules would be easy.</p>
  
  <p>The MAIN code is as below:</p>
  
  <pre><code>public static void Main(string[] args)
  {
     RetrieveData();
  }
  
  stativ void RetrieveData()
  {
      // Fetch data and send mails
  }
  </code></pre>
  
  <p>There are two problems:</p>
  
  <p>(1) I am not able to attach it to a process. First the issue is that as I start it in debugging mode, the application exits as soon as it hits Main when trying to Attach to process.</p>
  
  <p>(2) The .exe name is not appearing under process names when I click "Attach to Process".</p>
  
  <p>How to debug this application when it is executed from a task scheduler? It is not even executing when Task Scheduler triggers this job.</p>