| Author: B.Satishkumar 17 Aug 2008 | Member Level: Bronze | Rating: Points: 6 |
First Check ============ To do this, follow these steps: 1. Click Start, and then click Run. 2. In the Open text box, type regedit. 3. Locate the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application 4. Right-click the Application subkey, point to New, and then click Key. 5. Type TEST for the key name. 6. Close Registry Editor.
Second Approach The EventLogInstaller class in the System.Diagnostics namespace permits you to install and configure an event log that your application reads from or writes to while running. You can create an event source by using EventLogInstaller. To do this, follow these steps: 1. Use Microsoft Visual Basic .NET or Microsoft Visual C# .NET to create a new Class Library named EventLogSourceInstaller. By default, the Class1.vb file or the Class1.cs file is created. 2. In Solution Explorer, right-click EventLogSourceInstaller, and then click Add References. 3. In the Add Reference dialog box, double-click System.Configuration.Install.dll, and then click OK. 4. Rename the Class1.vb\Class1.cs to MyEventLogInstaller.vb\MyEventLogInstaller.cs. 5. Replace the existing code in MyEventLogInstaller.vb or MyEventLogInstaller.cs with the following sample code:
Visual Basic .NET SampleImports System.Diagnostics Imports System.Configuration.Install Imports System.ComponentModel
<RunInstaller(True)> _ Public Class MyEventLogInstaller Inherits Installer Private myEventLogInstaller As EventLogInstaller
Public Sub New() ' Create an instance of 'EventLogInstaller'. myEventLogInstaller = New EventLogInstaller() ' Set the 'Source' of the event log, to be created. myEventLogInstaller.Source = "TEST" ' Set the 'Log' that the source is created in. myEventLogInstaller.Log = "Application" ' Add myEventLogInstaller to 'InstallerCollection'. Installers.Add(myEventLogInstaller) End Sub End Class
6. On the Build menu, click Build Solution to create EventLogSourceInstaller.dll. 7. Open the Visual Studio .NET Command Prompt. 8. At the command prompt, change to the folder where EventLogSourceInstaller.dll is located. 9. Run the following command to create the EventSource: InstallUtil EventLogSourceInstaller.dll
|