|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.|
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.
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
On the File menu, point to New, and then click Project.
In the New Project dialog box, create a Visual Basic or Visual C# Windows Application. 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:
Save your files.
To create an installation component for your EventLog component
In the designer, click the EventLog1 component.
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.
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
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 Application 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.