Once you identify a source for a particular event log, this information is stored in the server's registry files until you remove that source. If you try to re-register a source that has already been registered as a valid source for a given log, a run-time error is raised. You can use the SourceExists method to determine whether or not a particular source has already been registered.
To determine if a source has already been registered on the local computer
[Visual Basic] If Not EventLog.SourceExists("MyApp1") Then EventLog.CreateEventSource("MyApp1", "Application") End If [C#] if (!EventLog.SourceExists("MyApp1")) EventLog.CreateEventSource("MyApp1", "Application");
To determine a source has already been registered on a remote computer
[Visual Basic] If Not EventLog.SourceExists("MyApp1", "myserver") Then EventLog.CreateEventSource("MyApp1", "Application") End If [C#] if (!EventLog.SourceExists("MyApp1", "myserver")) EventLog.CreateEventSource("MyApp1", "Application");