TechNet
Export (0) Print
Expand All

TransactedInstaller Class

 

Defines an installer that either succeeds completely or fails and leaves the computer in its initial state.

Namespace:   System.Configuration.Install
Assembly:  System.Configuration.Install (in System.Configuration.Install.dll)

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Configuration.Install.Installer
        System.Configuration.Install.TransactedInstaller

public class TransactedInstaller : Installer

NameDescription
System_CAPS_pubmethodTransactedInstaller()

Initializes a new instance of the TransactedInstaller class.

NameDescription
System_CAPS_protpropertyCanRaiseEvents

Gets a value indicating whether the component can raise an event.(Inherited from Component.)

System_CAPS_pubpropertyContainer

Gets the IContainer that contains the Component.(Inherited from Component.)

System_CAPS_pubpropertyContext

Gets or sets information about the current installation.(Inherited from Installer.)

System_CAPS_protpropertyDesignMode

Gets a value that indicates whether the Component is currently in design mode.(Inherited from Component.)

System_CAPS_protpropertyEvents

Gets the list of event handlers that are attached to this Component.(Inherited from Component.)

System_CAPS_pubpropertyHelpText

Gets the help text for all the installers in the installer collection.(Inherited from Installer.)

System_CAPS_pubpropertyInstallers

Gets the collection of installers that this installer contains.(Inherited from Installer.)

System_CAPS_pubpropertyParent

Gets or sets the installer containing the collection that this installer belongs to.(Inherited from Installer.)

System_CAPS_pubpropertySite

Gets or sets the ISite of the Component.(Inherited from Component.)

NameDescription
System_CAPS_pubmethodCommit(IDictionary)

When overridden in a derived class, completes the install transaction.(Inherited from Installer.)

System_CAPS_pubmethodCreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases all resources used by the Component.(Inherited from Component.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the Component and optionally releases the managed resources.(Inherited from Component.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.(Inherited from Component.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodGetService(Type)

Returns an object that represents a service provided by the Component or by its Container.(Inherited from Component.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodInstall(IDictionary)

Performs the installation.(Overrides Installer.Install(IDictionary).)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodOnAfterInstall(IDictionary)

Raises the AfterInstall event.(Inherited from Installer.)

System_CAPS_protmethodOnAfterRollback(IDictionary)

Raises the AfterRollback event.(Inherited from Installer.)

System_CAPS_protmethodOnAfterUninstall(IDictionary)

Raises the AfterUninstall event.(Inherited from Installer.)

System_CAPS_protmethodOnBeforeInstall(IDictionary)

Raises the BeforeInstall event.(Inherited from Installer.)

System_CAPS_protmethodOnBeforeRollback(IDictionary)

Raises the BeforeRollback event.(Inherited from Installer.)

System_CAPS_protmethodOnBeforeUninstall(IDictionary)

Raises the BeforeUninstall event.(Inherited from Installer.)

System_CAPS_protmethodOnCommitted(IDictionary)

Raises the Committed event.(Inherited from Installer.)

System_CAPS_protmethodOnCommitting(IDictionary)

Raises the Committing event.(Inherited from Installer.)

System_CAPS_pubmethodRollback(IDictionary)

When overridden in a derived class, restores the pre-installation state of the computer.(Inherited from Installer.)

System_CAPS_pubmethodToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.(Inherited from Component.)

System_CAPS_pubmethodUninstall(IDictionary)

Removes an installation.(Overrides Installer.Uninstall(IDictionary).)

NameDescription
System_CAPS_pubeventAfterInstall

Occurs after the Install methods of all the installers in the Installers property have run.(Inherited from Installer.)

System_CAPS_pubeventAfterRollback

Occurs after the installations of all the installers in the Installers property are rolled back.(Inherited from Installer.)

System_CAPS_pubeventAfterUninstall

Occurs after all the installers in the Installers property perform their uninstallation operations.(Inherited from Installer.)

System_CAPS_pubeventBeforeInstall

Occurs before the Install method of each installer in the installer collection has run.(Inherited from Installer.)

System_CAPS_pubeventBeforeRollback

Occurs before the installers in the Installers property are rolled back.(Inherited from Installer.)

System_CAPS_pubeventBeforeUninstall

Occurs before the installers in the Installers property perform their uninstall operations.(Inherited from Installer.)

System_CAPS_pubeventCommitted

Occurs after all the installers in the Installers property have committed their installations.(Inherited from Installer.)

System_CAPS_pubeventCommitting

Occurs before the installers in the Installers property committ their installations.(Inherited from Installer.)

System_CAPS_pubeventDisposed

Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)

To run installers in a transaction, add them to the Installers property of this TransactedInstaller instance.

The following example demonstrates the TransactedInstaller, Install and Uninstall methods of the TransactedInstaller class.

This example provides an implementation similar to that of Installutil.exe (Installer Tool). It installs assemblies with the options preceding that particular assembly. If an option is not specified for an assembly, the previous assembly's options are used if there is a previous assembly in the list. If either the "/u" or "/uninstall" option is specified, the assemblies are uninstalled. If the "/?" or "/help" option is provided, the help information is displayed to the console.

ArrayList myOptions = new ArrayList();
String myOption;
bool toUnInstall = false;
bool toPrintHelp = false;
TransactedInstaller myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller myAssemblyInstaller;
InstallContext myInstallContext;

try
{
   for(int i = 0; i < args.Length; i++)
   {
      // Process the arguments.
      if(args[i].StartsWith("/") || args[i].StartsWith("-"))
      {
         myOption = args[i].Substring(1);
         // Determine whether the option is to 'uninstall' an assembly.
         if(String.Compare(myOption, "u", true) == 0 ||
            String.Compare(myOption, "uninstall", true) == 0)
         {
            toUnInstall = true;
            continue;
         }
         // Determine whether the option is for printing help information.
         if(String.Compare(myOption, "?", true) == 0 ||
            String.Compare(myOption, "help", true) == 0)
         {
            toPrintHelp = true;
            continue;
         }
         // Add the option encountered to the list of all options
         // encountered for the current assembly.
         myOptions.Add(myOption);
      }
      else
      {
         // Determine whether the assembly file exists.
         if(!File.Exists(args[i]))
         {
            // If assembly file doesn't exist then print error.
            Console.WriteLine("\nError : {0} - Assembly file doesn't exist.",
               args[i]);
            return;
         }

         // Create a instance of 'AssemblyInstaller' that installs the given assembly.
         myAssemblyInstaller = 
            new AssemblyInstaller(args[i], 
            (string[]) myOptions.ToArray(typeof(string)));
         // Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.  
         myTransactedInstaller.Installers.Add(myAssemblyInstaller);
      }
   }
   // If user requested help or didn't provide any assemblies to install
   // then print help message.
   if(toPrintHelp || myTransactedInstaller.Installers.Count == 0)
   {
      PrintHelpMessage();
      return;
   }

   // Create a instance of 'InstallContext' with the options specified.
   myInstallContext = 
      new InstallContext("Install.log", 
      (string[]) myOptions.ToArray(typeof(string)));
   myTransactedInstaller.Context = myInstallContext;

   // Install or Uninstall an assembly depending on the option provided.
   if(!toUnInstall)
      myTransactedInstaller.Install(new Hashtable());
   else
      myTransactedInstaller.Uninstall(null);
}
catch(Exception e)
{
   Console.WriteLine("\nException raised : {0}", e.Message);
}  

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft