InstallEventArgs Class
Provides data for the events: BeforeInstall, AfterInstall, Committing, Committed, BeforeRollback, AfterRollback, BeforeUninstall, AfterUninstall.
Assembly: System.Configuration.Install (in System.Configuration.Install.dll)
The InstallEventArgs type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | InstallEventArgs() | Initializes a new instance of the InstallEventArgs class, and leaves the SavedState property empty. |
![]() | InstallEventArgs(IDictionary) | Initializes a new instance of the InstallEventArgs class, and specifies the value for the SavedState property. |
| Name | Description | |
|---|---|---|
![]() | SavedState | Gets an IDictionary that represents the current state of the installation. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
InstallEventArgs contains an IDictionary that holds information about the current state of the installation. The BeforeInstall, AfterInstall, Committing, Committed, BeforeRollback, AfterRollback, BeforeUninstall, and AfterUninstall event handlers use this information.
The following example demonstrates the InstallEventArgs constructors and the SavedState property of the InstallEventArgs class.
There are two new events called BeforeCommit and AfterCommit. The handlers of these events are invoked from the protected methods named OnBeforeCommit and OnAfterCommit respectively. These events are raised when the Commit method is called.
#using <System.dll> #using <System.Configuration.Install.dll> using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Configuration::Install; using namespace System::IO; [RunInstaller(true)] ref class MyInstaller: public Installer { public: // Simple events to handle before and after commit handlers. event InstallEventHandler^ BeforeCommit; event InstallEventHandler^ AfterCommit; MyInstaller() { // Add handlers to the events. BeforeCommit += gcnew InstallEventHandler( this, &MyInstaller::BeforeCommitHandler ); AfterCommit += gcnew InstallEventHandler( this, &MyInstaller::AfterCommitHandler ); } virtual void Install( IDictionary^ savedState ) override { Installer::Install( savedState ); Console::WriteLine( "Install ...\n" ); } virtual void Commit( IDictionary^ savedState ) override { Console::WriteLine( "Before Committing ...\n" ); // Call the 'OnBeforeCommit' protected method. OnBeforeCommit( savedState ); Installer::Commit( savedState ); Console::WriteLine( "Committing ...\n" ); // Call the 'OnAfterCommit' protected method. OnAfterCommit( savedState ); Console::WriteLine( "After Committing ...\n" ); } virtual void Rollback( IDictionary^ savedState ) override { Installer::Rollback( savedState ); Console::WriteLine( "RollBack ...\n" ); } virtual void Uninstall( IDictionary^ savedState ) override { Installer::Uninstall( savedState ); Console::WriteLine( "UnInstall ...\n" ); } // Protected method that invoke the handlers associated with the 'BeforeCommit' event. protected: virtual void OnBeforeCommit( IDictionary^ savedState ) { BeforeCommit( this, gcnew InstallEventArgs( savedState ) ); } // Protected method that invoke the handlers associated with the 'AfterCommit' event. protected: virtual void OnAfterCommit( IDictionary^ savedState ) { AfterCommit( this, gcnew InstallEventArgs ); } // A simple event handler to exemplify the example. void BeforeCommitHandler( Object^ sender, InstallEventArgs^ e ) { Console::WriteLine( "BeforeCommitHandler event handler has been called\n" ); Console::WriteLine( "The count of saved state objects are : {0}\n", e->SavedState->Count ); } // A simple event handler to exemplify the example. private: void AfterCommitHandler( Object^ sender, InstallEventArgs^ e ) { Console::WriteLine( "AfterCommitHandler event handler has been called\n" ); } };
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
