|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Walkthrough: Installing an Event Log Component
The procedures in this topic walk you through the process of setting up an installation component for an instance of the EventLog component, including creating the component instance, adding an installer for it, and compiling and running the installer.
To create your EventLog component
- On the File menu, point to New, and then click Project.
- In the New Project dialog box, choose Visual Basic or Visual C# in the left pane, then choose the Windows Application template. Name the project MyEventLog.
- From the Components tab of the Toolbox, drag an EventLog component to the form.
- In the Properties window, set the following values:
- Set the Log property to Application.
- Set the MachineName property to the name of the server on which the event log resides. Use a period (.) for the local computer.
- Set the Source property to the string of your choice. In this case, you can use the name of your project.
- Save your files.
Note For more information on creating EventLog component instances and setting their properties, see Logging Application, Server, and Security Events.
To create an installation component for your EventLog component
- In the designer, click the EventLog1 component.
- In the Description area at the bottom of the Properties window, click the Add Installer link.
A ProjectInstaller class appears in your project, and an installation component is added to it.
You can now install and run your application.
To build your installation
- Save your project and build it.
Note Because this installer will function correctly without changing the existing methods, you do not need to override the Install, Commit, Rollback, and Uninstall methods.
A setup project will install the compiled project files and run the installers needed to run a Windows application.
To create a setup project for your application
- On the File menu, point to Add Project, then click New Project.
- In the Project Types pane, select the Setup and Deployment Projects folder.
- In the Templates pane, select Setup Project. Name the project MyEventLogSetup.
A setup project is added to the solution.
Next you will add the output from the Windows Service project to the setup.
To add the project output to the setup
- In Solution Explorer, right-click MyEventLogSetup, point to Add, then choose Project Output.
The Add Project Output Group dialog box appears.
- MyEventLog is selected in the Project box.
- In the list box, select Primary Output, then click OK.
A project item for the primary output of MyEventLog is added to the setup project.
Now add a custom action to install the MyNewService.exe file.
To add a custom action to the setup
- In Solution Explorer, right-click the setup project, point to View, then choose Custom Actions.
The Custom Actions editor appears.
- In the Custom Actions editor, right-click the Custom Actions node and choose Add Custom Action.
The Select Item in Project dialog box appears.
- Double-click the Application Folder in the list box to open it, select Primary Output from MyEventLog (Active), and click OK.
The primary output is added to all four nodes of the custom actions, Install, Commit, Rollback, and Uninstall.
- Build the setup project.
- To install MyEventLog.exe, right-click the setup project in the Solution Explorer and select Install.