ServiceInstaller.Uninstall Method
Uninstalls the service by removing information about it from the registry.
Assembly: System.ServiceProcess (in System.ServiceProcess.dll)
Parameters
- savedState
- Type: System.Collections.IDictionary
An IDictionary that contains the context information associated with the installation.
| Exception | Condition |
|---|---|
| Win32Exception |
The Service Control Manager could not be opened. -or- The system could not get a handle to the service. |
Uninstall first attempts to stop the service before uninstalling it. If the service cannot be stopped, no exception is caught, and the method continues with the removal of the service.
Normally, you will not call the methods on ServiceInstaller within your code; they are generally called only by the install utility. InstallUtil is used to uninstall services as well as install them; uninstalling takes a switch in the command line call.
An application's uninstall routine maintains information automatically about the components being uninstalled, using the project installer's Installer.Context. This state information, passed into Uninstall as the savedState parameter, is continuously updated as the ServiceProcessInstaller instance and each ServiceInstaller instance is installed by the utility. It is usually unnecessary for your code to modify this state information explicitly.
For all classes deriving from the Installer class, the state of the Installers collection must be the same in the Install and Uninstall methods. However, you can avoid the maintenance of the collection across the Install and Uninstall methods if you add installer instances to the Installers collection in your custom installer class constructor.
There is no rollback mechanism for uninstalling, so if one service fails to uninstall, this does not affect the other services (usually within the same installation project) being uninstalled.
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
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.