TransactedInstaller Class
Defines an installer that either succeeds completely or fails and leaves the computer in its initial state.
Assembly: System.Configuration.Install (in System.Configuration.Install.dll)
System::MarshalByRefObject
System.ComponentModel::Component
System.Configuration.Install::Installer
System.Configuration.Install::TransactedInstaller
| Name | Description | |
|---|---|---|
![]() | TransactedInstaller() | Initializes a new instance of the TransactedInstaller class. |
| Name | Description | |
|---|---|---|
![]() | CanRaiseEvents | Gets a value indicating whether the component can raise an event.(Inherited from Component.) |
![]() | Container | Gets the IContainer that contains the Component.(Inherited from Component.) |
![]() | Context | Gets or sets information about the current installation.(Inherited from Installer.) |
![]() | DesignMode | |
![]() | Events | |
![]() | HelpText | Gets the help text for all the installers in the installer collection.(Inherited from Installer.) |
![]() | Installers | Gets the collection of installers that this installer contains.(Inherited from Installer.) |
![]() | Parent | Gets or sets the installer containing the collection that this installer belongs to.(Inherited from Installer.) |
![]() | Site |
| Name | Description | |
|---|---|---|
![]() | Commit(IDictionary^) | When overridden in a derived class, completes the install transaction.(Inherited from Installer.) |
![]() | CreateObjRef(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.) |
![]() | Dispose() | |
![]() | Dispose(Boolean) | |
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetLifetimeService() | Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.) |
![]() | GetService(Type^) | |
![]() | GetType() | |
![]() | InitializeLifetimeService() | Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.) |
![]() | Install(IDictionary^) | Performs the installation.(Overrides Installer::Install(IDictionary^).) |
![]() | MemberwiseClone() | |
![]() | MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.) |
![]() | OnAfterInstall(IDictionary^) | Raises the AfterInstall event.(Inherited from Installer.) |
![]() | OnAfterRollback(IDictionary^) | Raises the AfterRollback event.(Inherited from Installer.) |
![]() | OnAfterUninstall(IDictionary^) | Raises the AfterUninstall event.(Inherited from Installer.) |
![]() | OnBeforeInstall(IDictionary^) | Raises the BeforeInstall event.(Inherited from Installer.) |
![]() | OnBeforeRollback(IDictionary^) | Raises the BeforeRollback event.(Inherited from Installer.) |
![]() | OnBeforeUninstall(IDictionary^) | Raises the BeforeUninstall event.(Inherited from Installer.) |
![]() | OnCommitted(IDictionary^) | |
![]() | OnCommitting(IDictionary^) | Raises the Committing event.(Inherited from Installer.) |
![]() | Rollback(IDictionary^) | When overridden in a derived class, restores the pre-installation state of the computer.(Inherited from Installer.) |
![]() | ToString() | |
![]() | Uninstall(IDictionary^) | Removes an installation.(Overrides Installer::Uninstall(IDictionary^).) |
| Name | Description | |
|---|---|---|
![]() | AfterInstall | Occurs after the Install methods of all the installers in the Installers property have run.(Inherited from Installer.) |
![]() | AfterRollback | Occurs after the installations of all the installers in the Installers property are rolled back.(Inherited from Installer.) |
![]() | AfterUninstall | Occurs after all the installers in the Installers property perform their uninstallation operations.(Inherited from Installer.) |
![]() | BeforeInstall | |
![]() | BeforeRollback | Occurs before the installers in the Installers property are rolled back.(Inherited from Installer.) |
![]() | BeforeUninstall | Occurs before the installers in the Installers property perform their uninstall operations.(Inherited from Installer.) |
![]() | Committed | Occurs after all the installers in the Installers property have committed their installations.(Inherited from Installer.) |
![]() | Committing | Occurs before the installers in the Installers property committ their installations.(Inherited from Installer.) |
![]() | Disposed |
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.
array<String^>^ args = Environment::GetCommandLineArgs(); ArrayList^ myOptions = gcnew ArrayList; String^ myOption; bool toUnInstall = false; bool toPrintHelp = false; TransactedInstaller^ myTransactedInstaller = gcnew TransactedInstaller; AssemblyInstaller^ myAssemblyInstaller; InstallContext^ myInstallContext; try { for ( int i = 1; 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 0; } // Create a instance of 'AssemblyInstaller' that installs the given assembly. myAssemblyInstaller = gcnew AssemblyInstaller( args[ i ], (array<String^>^)( myOptions->ToArray( String::typeid ) ) ); // 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 0; } // Create a instance of 'InstallContext' with the options specified. myInstallContext = gcnew InstallContext( "Install.log", (array<String^>^)( myOptions->ToArray( String::typeid ) ) ); myTransactedInstaller->Context = myInstallContext; // Install or Uninstall an assembly depending on the option provided. if ( !toUnInstall ) { myTransactedInstaller->Install( gcnew Hashtable ); } else { myTransactedInstaller->Uninstall( nullptr ); } } catch ( Exception^ e ) { Console::WriteLine( "\nException raised : {0}", e->Message ); }
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.




