Given the following code
InitializeComponent();
try
{
if (!System.Diagnostics.EventLog.SourceExists(this.ServiceName))
{
System.Diagnostics.EventLog.CreateEventSource(
this.ServiceName, "ProfileWatcherLog");
}
profileWatcherLog.Source = this.ServiceName;
profileWatcherLog.Log = "ProfileWatcherLog";
}
catch (Exception e)
{
profileWatcherLog.WriteEntry(String.Format("ERROR: {0}",e.Message));
}
finally
{
profileWatcherLog.WriteEntry("Profile Watcher setup");
}
If I use an already existing event log source it works fine, but if I try the event source I want to use for this application then it fails.
I have even tried the following; which uses the properties of the profileWatcherLog and the ServiceName and it still fails.
if (!System.Diagnostics.EventLog.SourceExists(this.ServiceName))
{
System.Diagnostics.EventLog.CreateEventSource(
this.ServiceName, profileWatcherLog.Log);
}
profileWatcherLog.Source = this.ServiceName;
Anyone see what I have done wrong?
Thanks in advance