Export (0) Print
Expand All

Installer.Uninstall Method

When overridden in a derived class, removes an installation.

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

Parameters

savedState
An IDictionary that contains the state of the computer after the installation was complete.

Exceptions

Exception Type Condition
ArgumentException The saved-state IDictionary might have been corrupted.
InstallException An exception occurred while uninstalling. This exception is ignored and the uninstall continues. However, the application might not be fully uninstalled after the uninstallation completes.

Remarks

Notes to Inheritors:  When you override the Uninstall method in a derived class, be sure to call the base class's Uninstall method first in your derived method. The Uninstall method is called to remove a previously completed installation. If the uninstallation fails for one installer in the collection, the remaining installers are still uninstalled. A failed uninstallation does not roll back the computer to its pre-uninstallation state. Although the Install and Commit methods save the state of the computer after the installations, the file containing the IDictionary from the savedState parameter might have been deleted at some point after the installation was complete. If the file is deleted, the savedState parameter is a null reference (Nothing in Visual Basic). Your Uninstall method should be able to handle the case of a null reference (Nothing) savedState parameter.

Example

[Visual Basic, C#, C++] The following example demonstrates the Uninstall method of Installer. The Uninstall method is overridden in the derived class of Installer.

[Visual Basic] 
' Override 'Uninstall' method of Installer class.
Public Overrides Sub Uninstall(mySavedState As IDictionary)
   If mySavedState Is Nothing Then
      Console.WriteLine("Uninstallation Error !")
   Else
      MyBase.Uninstall(mySavedState)
      Console.WriteLine("The Uninstall method of 'MyInstallerSample' has been called")
   End If
End Sub 'Uninstall

[C#] 
// Override 'Uninstall' method of Installer class.
public override void Uninstall( IDictionary mySavedState )
{  
   if (mySavedState == null)
   {
      Console.WriteLine("Uninstallation Error !");
   }
   else
   {
      base.Uninstall( mySavedState );
      Console.WriteLine( "The Uninstall method of 'MyInstallerSample' has been called" );
   }
}

[C++] 
// Override 'Uninstall' method of Installer class.
void Uninstall(IDictionary* mySavedState) {
    if (mySavedState == 0) {
        Console::WriteLine(S"Uninstallation Error !");
    } else {
        Installer::Uninstall(mySavedState);
        Console::WriteLine(S"The Uninstall 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 | Install | Commit | Rollback | InstallerCollection | Installers

Show:
© 2014 Microsoft