I searched a lot on this, and finally figured out it was my coding mistake.
I created an EventLog as EventLog(logName, sourceName);
When I checked the constructor, it was EventLog(logName, machineName)..
Now it all makes sense.. 🙂
UPDATE: I actually had to make use of the EventLog(logName, machineName) constructor to support viewing a remote event log, and had an issue with Network Path Not Found when I tried to use
new EventLog(“logName”, “localhost”);
The fix is
- Use new EventLog(“logName”, “.”) for localhost
- For actual remote machines, make sure the “Remote Registry” service is running on the machine. (When this service is running, new EventLog(“logName”, “localhost”) also works