Installer.Uninstall(IDictionary) 方法

定义

在派生类中重写时,移除安装。When overridden in a derived class, removes an installation.

public:
 virtual void Uninstall(System::Collections::IDictionary ^ savedState);
public virtual void Uninstall (System.Collections.IDictionary savedState);
abstract member Uninstall : System.Collections.IDictionary -> unit
override this.Uninstall : System.Collections.IDictionary -> unit
Public Overridable Sub Uninstall (savedState As IDictionary)

参数

savedState
IDictionary

IDictionary,它包含安装完成后计算机的状态。An IDictionary that contains the state of the computer after the installation was complete.

异常

保存的状态 IDictionary 可能已损坏。The saved-state IDictionary might have been corrupted.

卸载时发生异常。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.

示例

下面的示例演示UninstallInstaller方法。The following example demonstrates the Uninstall method of Installer. 方法在的Installer派生类中被重写。 UninstallThe Uninstall method is overridden in the derived class of Installer.

   // Override 'Uninstall' method of Installer class.
public:
   virtual void Uninstall( IDictionary^ mySavedState ) override
   {
      if ( mySavedState == nullptr )
      {
         Console::WriteLine( "Uninstallation Error !" );
      }
      else
      {
         Installer::Uninstall( mySavedState );
         Console::WriteLine( "The Uninstall method of 'MyInstallerSample' has been called" );
      }
   }
// 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" );
   }
}
' 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

继承者说明

-如果在派生类Install(IDictionary)中重写方法, 请确保先在派生方法中调用基类Install(IDictionary)的方法。- If you override the Install(IDictionary) method in a derived class, be sure to call the base class's Install(IDictionary) method first in your derived method. 方法调用此实例的Installers属性中包含的每个安装程序的方法。Install(IDictionary) Install(IDictionary)The Install(IDictionary) method calls the Install(IDictionary) method of each installer contained in the Installers property of this instance. 在包含的安装程序运行后, 此方法IDictionary更新对象 ( stateSaver通过参数指定) 以反映安装的状态。After the contained installers run, this method updates the IDictionary object (specified through the stateSaver parameter) to reflect the status of the installation. IDictionary 传递Install(IDictionary)给方法时, 应为空。The IDictionary should be empty when passed to the Install(IDictionary) method. 如果所有Install(IDictionary)方法均成功Commit(IDictionary) , 则调用方法。If all the Install(IDictionary) methods succeed, the Commit(IDictionary) method is called. 否则, Rollback(IDictionary)将调用方法。Otherwise, the Rollback(IDictionary) method is called.

-如果需要将安装程序实例添加到Installers Install(IDictionary)方法中的集合, 请确保在Uninstall(IDictionary)方法中对集合执行相同的添加。- If you need to add installer instances to the Installers collection in the Install(IDictionary) method, be sure to perform the same additions to the collection in the Uninstall(IDictionary) method. 但是, 如果将安装程序实例添加到自定义安装程序的类构造函数中Installers的集合, 则可以避免在这两种方法中维护该集合。However, you can avoid maintaining the collection in both methods if you add installer instances to the Installers collection in the class constructor for your custom installer.

适用于

另请参阅