Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Installer.Install Method

When overridden in a derived class, performs the installation.

[Visual Basic]
Public Overridable Sub Install( _
   ByVal stateSaver As IDictionary _
)
[C#]
public virtual void Install(
 IDictionary stateSaver
);
[C++]
public: virtual void Install(
 IDictionary* stateSaver
);
[JScript]
public function Install(
   stateSaver : IDictionary
);

Parameters

stateSaver
An IDictionary used to save information needed to perform a commit, rollback, or uninstall operation.

Exceptions

Exception Type Condition
ArgumentException The stateSaver parameter is a null reference (Nothing in Visual Basic).
Exception An exception occurred in the BeforeInstall event handler of one of the installers in the collection.

-or-

An exception occurred in the AfterInstall event handler of one of the installers in the collection.

Remarks

Notes to Inheritors:  If you override the Install method in a derived class, be sure to call the base class's Install method first in your derived method. The Install method calls the Install method of each installer contained in the Installers property of this instance. After the contained installers run, this method updates the IDictionary object (specified through the stateSaver parameter) to reflect the status of the installation. The IDictionary should be empty when passed to the Install method. If all the Install methods succeed, the Commit method is called. Otherwise, the Rollback method is called.

Example

[Visual Basic, C#, C++] The following example demonstrates the Install method of the Installer class. A class is derived from the Installer base class and the Install method is overridden.

[Visual Basic] 
' Override the 'Install' method of the Installer class.
Public Overrides Sub Install(mySavedState As IDictionary)
   MyBase.Install(mySavedState)
   ' Code maybe written for installation of an application.
   Console.WriteLine("The Install method of 'MyInstallerSample' has been called")
End Sub 'Install

[C#] 
// Override the 'Install' method of the Installer class.
public override void Install( IDictionary mySavedState )
{
   base.Install( mySavedState );
   // Code maybe written for installation of an application.
   Console.WriteLine( "The Install method of 'MyInstallerSample' has been called" );
}

[C++] 
// Override the 'Install' method of the Installer class.
void Install(IDictionary* mySavedState) {
    Installer::Install(mySavedState);
    // Code maybe written for installation of an application.
    Console::WriteLine(S"The Install method of 'MyInstallerSample' has been called");
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

Installer Class | Installer Members | System.Configuration.Install Namespace | Commit | IDictionary | InstallerCollection | Installers | Rollback | Uninstall

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.