Installer.BeforeInstall 事件

在安装程序集合中每个安装程序的 Install 方法运行前发生。

**命名空间:**System.Configuration.Install
**程序集:**System.Configuration.Install(在 system.configuration.install.dll 中)

语法

声明
Public Event BeforeInstall As InstallEventHandler
用法
Dim instance As Installer
Dim handler As InstallEventHandler

AddHandler instance.BeforeInstall, handler
public event InstallEventHandler BeforeInstall
public:
event InstallEventHandler^ BeforeInstall {
    void add (InstallEventHandler^ value);
    void remove (InstallEventHandler^ value);
}
/** @event */
public void add_BeforeInstall (InstallEventHandler value)

/** @event */
public void remove_BeforeInstall (InstallEventHandler value)
JScript 支持使用事件,但不支持进行新的声明。

示例

下面的示例说明 BeforeInstall 事件。它由 OnBeforeInstall 方法引发。

' MyInstaller is derived from the class 'Installer'.
Sub New()
   MyBase.New()
   AddHandler BeforeInstall, AddressOf BeforeInstallEventHandler
End Sub 'New

Private Sub BeforeInstallEventHandler(sender As Object, e As InstallEventArgs)
   ' Add steps to perform any actions before the install process.
   Console.WriteLine("Code for BeforeInstallEventHandler")
End Sub 'BeforeInstallEventHandler
// MyInstaller is derived from the class 'Installer'.
MyInstaller() : base()
{
   BeforeInstall += new InstallEventHandler(BeforeInstallEventHandler);
}
private void BeforeInstallEventHandler(object sender, InstallEventArgs e)
{
   // Add steps to perform any actions before the install process.
   Console.WriteLine("Code for BeforeInstallEventHandler"); 
}
   // MyInstaller is derived from the class 'Installer'.
private:
   MyInstaller()
   {
      BeforeInstall += gcnew InstallEventHandler( this, &MyInstaller::BeforeInstallEventHandler );
   }

   void BeforeInstallEventHandler( Object^ sender, InstallEventArgs^ e )
   {
      // Add steps to perform any actions before the install process.
      Console::WriteLine( "Code for BeforeInstallEventHandler" );
   }
// MyInstaller is derived from the class 'Installer'.
MyInstaller()
{
    this.add_BeforeInstall(
        new InstallEventHandler(BeforeInstallEventHandler));
} //MyInstaller

private void BeforeInstallEventHandler(Object sender, InstallEventArgs e)
{
    // Add steps to perform any actions before the install process.
    Console.WriteLine("Code for BeforeInstallEventHandler");
} //BeforeInstallEventHandler

.NET Framework 安全性

  • 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

Installer 类
Installer 成员
System.Configuration.Install 命名空间
Installer.AfterInstall 事件
OnAfterInstall
OnBeforeInstall