Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27046

VS 2010 Creating EventLog sources dynamically, requires a reboot if you wish to use a...

$
0
0
I would like to create an EventLog for my application, let's call it "myApp Log". I then want to include a source which will be different depending on my service name. For instance, I have two services (serviceA and serviceB). When the service starts I check to see if the EventLog.Source is created before I try writing to it.

I do that by:

vb.NET Code:
  1. If Not System.Diagnostics.EventLog.SourceExists(svcName) Then
  2.                 System.Diagnostics.EventLog.CreateEventSource(svcName, "myApp Log")
  3.             End If

If it doesn't exist, and there will be times where it wont exist based on the user installing the service and the name they provide at install time or in the app.config files, then I have to create it. The issue is that when I create it, it doesn't register the source to "myApp Log" instead it registers it to the "Applications Log."

The PC, where the service remains, must be restarted so that the source will be mapped to the correct Event Log. How can I do this without requiring the reboot?

Viewing all articles
Browse latest Browse all 27046

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>