Share via


Walkthrough: Installing an Event Log Component

The procedures on this page 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.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To create your EventLog component

  1. On the File menu, point to New, and then click Project.

  2. In the New Project dialog box, create a Visual Basic or Visual C# Windows Application. Name the project MyEventLog.

  3. From the Components tab of the Toolbox, drag an EventLog component to the form.

  4. 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.

  5. 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

  1. In the designer, click the EventLog1 component.

  2. With the designer in focus, right-click, and then click Add Installer.

    An Installer 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 installs the compiled project files and runs the installers needed to run a Windows application.

To create a setup project for your application

  1. On the File menu, point to Add Project, then click New Project.

  2. In the Project Types pane, select the Setup and Deployment Projects folder.

  3. 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 Application project to the setup.

To add the project output to the setup

  1. In Solution Explorer, right-click MyEventLogSetup, point to Add, then choose Project Output.

    The Add Project Output Group dialog box appears.

  2. MyEventLog is selected in the Project box.

  3. 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

  1. In Solution Explorer, right-click the setup project, point to View, then choose Custom Actions.

    The Custom Actions editor appears.

  2. In the Custom Actions editor, right-click the Custom Actions node and choose Add Custom Action.

    The Select Item in Project dialog box appears.

  3. 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.

  4. Build the setup project.

  5. To install MyEventLog.exe, right-click the setup project in the Solution Explorer and select Install.

See Also

Tasks

How to: Launch Event Viewer from the Server Explorer

Concepts

Introduction to Installation Components

Other Resources

Logging Application, Server, and Security Events

System Monitoring Walkthroughs