title: windows service screen capture returns black screen
body: <p>I'm trying to create windows service application to capture screen. Previously i had <a href="https://stackoverflow.com/questions/18870987/screen-capture-using-windows-service#comment27848757_18870987">problem </a> of starting the service. Anyhow I'm able to solved it and now I'm having another problem. Now image is saving but it saves as a black screen. for this also there's lot of questions asked in SOF, but i couldn't able to solve my problem.</p>
  
  <p>Here what i have tried so far:</p>
  
  <pre><code> public partial class ScreenCaptureService : ServiceBase
      {           
          private static Bitmap bmpScreenshot;
          //private static Graphics gfxScreenshot;
          System.Timers.Timer timer = new System.Timers.Timer();
          public ScreenCaptureService()
          {
              InitializeComponent();
          }
  
          protected override void OnStart(string[] args)
          {              
              TraceService();
              timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
  
              timer.Interval = 60000;
              timer.Enabled = true;
          }
  
          protected override void OnStop()
          {
              timer.Enabled = false;
              TraceService();    
          }
  
          private void TraceService()
          {    
              Desktop userDesk = new Desktop();
              userDesk.BeginInteraction();
              string path = @"D:\Screen\";
              if (!Directory.Exists(path))
                  Directory.CreateDirectory(path);
  
              string fileName = string.Format("SCR-{0:yyyy-MM-dd_hh-mm-ss-tt}.png", DateTime.Now);    
              string filePath = path + fileName;
              bmpScreenshot = CaptureScreen.GetDesktopImage();
              bmpScreenshot.Save(filePath, ImageFormat.Png);
              userDesk.EndInteraction();
          }
  
          private void OnElapsedTime(object source, ElapsedEventArgs e)
          {
              TraceService();
          }      
      }
  </code></pre>
  
  <p>in here i followed codes mentioned in <a href="http://www.csharphelp.com/2006/11/capturing-the-screen-image-using-c/" rel="nofollow noreferrer">Here</a> and <a href="https://stackoverflow.com/a/4935491">Here</a>. but it don't works for me.</p>
  
  <p>I'm using windows 7 pc. i saw several answers mentioned about <code>the session 0 isolation feature</code> but i couldn't get proper solution from them.  </p>
  
  <p><strong>EDIT</strong>
  here this service runs as <code>session 0</code>
  <img src="https://i.stack.imgur.com/ClXPz.png" alt="task manager"></p>