C #: захват экрана из службы Windows

я должен делать снимок экрана рабочего стола через каждую секунду. в приложении Winform все работает нормально. но после перемещения кода в службу Windows он не захватывает снимок экрана. Есть идеи, почему это не так?

вот код

public partial class ScreenCaptureService : ServiceBase
    {
        System.Timers.Timer timer = new System.Timers.Timer();

        public ScreenCaptureService()
        {
            InitializeComponent();            
            this.timer.Interval = 1000;
            this.timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);

        }

        void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            CaptureScreen();
        }

        protected override void OnStart(string[] args)
        {
            if (!EventLog.SourceExists(this.ServiceName, Environment.MachineName))
            {
                EventLog.CreateEventSource(
                    new EventSourceCreationData(
                        this.ServiceName,
                        Environment.MachineName
                        )
                );
            }

            EventLog.WriteEntry(this.ServiceName, "The OnStart event has been called");
            this.timer.Enabled = true;
            CaptureScreen();
        }

        protected override void OnStop()
        {
            EventLog.WriteEntry(this.ServiceName, "The OnStop event has been called");
            this.timer.Enabled = false;
        }

        static int count = 1;
        private void CaptureScreen()
        {

            Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

            Graphics graphics = Graphics.FromImage(printscreen as Image);

            graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);

            printscreen.Save(@"C:\printscreen" + count++ + ".jpg", ImageFormat.Jpeg);

            EventLog.WriteEntry(this.ServiceName, "Screenshot Captured");
        }
}

Ответы на вопрос(1)

Ваш ответ на вопрос