Installation Components

Team-Fly    

Developing XML Web Services and Server Components with Visual C#™ .NET and the .NET Framework, Exam Cram™ 2 (Exam 70-320)
By Amit Kalani, Priti Kalani

Table of Contents
Chapter 11.  Deployment


The .NET Framework provides the Installer class, which is defined in the System.Configuration.Install namespace. This class works as a base class for all the custom installers in the .NET Framework and is specifically designed to help you perform customized installation actions.

Some of the important members of the Installer class are listed in Table 14.2.

Table 14.2. Important Members of the Installer Class

Member Name

Type

Description

Commit()

Method

Executes if the Install() method executes successfully

Install()

Method

Performs the specified actions during an application's installation

Installers

Property

Specifies a collection of Installer objects that are needed for this Installer instance to successfully install a component

Rollback()

Method

Is called if the Install() method fails to undo any custom actions performed during the Install() method

Uninstall()

Method

Performs the specified actions when a previously installed application is uninstalled

You can derive a class from the Installer class and override the methods listed in Table 14.2 to perform any custom actions. Alternatively, you can use the predefined installation components associated with most of the components in Server Explorer. For example, when you select Add Installer from the shortcut menu of the EventLog component, a ProjectInstaller class is created in the project, and the installation component for the EventLog component is added to this class. If you add more installation components (for example, a PerformanceCounter installation component) to this project, they are all added to this ProjectInstaller class. These installation components are actually added to the Installers collection of the ProjectInstaller class. When you compile the project to build an EXE or a DLL file, the ProjectInstaller class is part of the output assembly.

If you want the derived Installer class to execute when an assembly is installed, you need to apply the RunInstaller attribute on the class and set its value to true, like this:

 [RunInstaller(true)] 

You can deploy an assembly that contains installation components in the following ways:

  • Using the Web setup project To deploy an application that consists of installation components, you need to create a Web setup project as you normally would. However, this time, you use the Custom Actions Editor to deploy the necessary additional resources. At the time of deployment, the deployment project executes the ProjectInstaller class as a part of its custom installation action to create component resources.

  • Using the Installer tool You can also use the command-line Installer tool (installutil.exe) to install the assemblies that contain additional component resources. To install the resources contained in an assembly named Assembly1.dll, you could use the following form of the installutil.exe command:

     installutil.exe Assembly1.dll 

    You can also install resources contained in multiple assemblies, as follows:

     installutil.exe Assembly1.dll Assembly2.dll Assembly3.dll 

    If you instead want to launch the uninstaller for installation classes stored in an assembly, you can use the /u or /uninstall options with the command, as follows:

     installutil.exe /u Assembly1.dll 

graphics/alert_icon.gif

If you are installing components from multiple assemblies using the installutil.exe command and any assembly fails to install, installutil.exe rolls back the installations of all the other assemblies. However, the process of uninstallation is not transactional.



    Team-Fly    
    Top


    MCAD Developing XML Web Services and Server Components with Visual C#. NET and the. NET Framework Exam Cram 2 (Exam Cram 70-320)
    Managing Globally with Information Technology
    ISBN: 789728974
    EAN: 2147483647
    Year: 2002
    Pages: 179

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net