From e4844c562a8cf64d0a6d2624bdb51e25eae05ef0 Mon Sep 17 00:00:00 2001 From: James Botting Date: Tue, 24 Nov 2015 16:59:51 +0000 Subject: [PATCH] Fix Logging Error --- .gitignore | 9 ++++++++- RemoteDesktopService/RemoteAppDesktopService.cs | 16 ++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a58590d..189ace0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,8 @@ -/.vs/RemoteDesktopService/v14/*.suo +*.user + +bin + +obj + +.vs +*.suo diff --git a/RemoteDesktopService/RemoteAppDesktopService.cs b/RemoteDesktopService/RemoteAppDesktopService.cs index 8e27c8b..899914f 100644 --- a/RemoteDesktopService/RemoteAppDesktopService.cs +++ b/RemoteDesktopService/RemoteAppDesktopService.cs @@ -10,12 +10,11 @@ public partial class RemoteAppDesktopService : ServiceBase { #region Service Template public RegistryMonitor Thread; - public RemoteAppDesktopService() { InitializeComponent(); - _GetEventLog(); + Thread = new RegistryMonitor(this, this.ApplicationEventLog); } @@ -38,13 +37,18 @@ protected override void OnStop() #region Service Methods protected void _GetEventLog() { - if( !EventLog.SourceExists("DesktopAppMonitor") ) + try { - EventLog.CreateEventSource("RemoteApp Desktop Monitor", "Application"); + if( !EventLog.SourceExists("RemoteApp Desktop Monitor") ) + { + EventLog.CreateEventSource("RemoteApp Desktop Monitor", "Application"); + } + + this.ApplicationEventLog.Source = "RemoteApp Desktop Monitor"; + this.ApplicationEventLog.Log = "Application"; } + catch( Exception ) {} - this.ApplicationEventLog.Source = "RemoteApp Desktop Monitor"; - this.ApplicationEventLog.Log = "Application"; } #endregion Service Methods }