I have the following piece of code that works well in windows server 2003. It writes to the Application Event Log in EventViwer. The same code doesnt work in Windows 2008 The aplication crashes.Request to help on how to write to event log in Windows Server 2008.
if (!EventLog.SourceExists("MyServiceLog"))
{
EventLog.CreateEventSource("MyServiceLog", "Application");
}
//Create an EventLog instance and assign its source.
EventLog eventLog = new EventLog();
eventLog.Source = "MyServiceLog";
//Write an informational entry to the event log.
eventLog.WriteEntry(Header + ": " + FailureReason);