本文整理匯總了C#中System.Configuration.Install.Installer.BeforeRollback事件的典型用法代碼示例。如果您正苦於以下問題:C# Installer.BeforeRollback事件的具體用法?C# Installer.BeforeRollback怎麽用?C# Installer.BeforeRollback使用的例子?那麽, 這裏精選的事件代碼示例或許可以為您提供幫助。您也可以進一步了解該事件所在類System.Configuration.Install.Installer
的用法示例。
在下文中一共展示了Installer.BeforeRollback事件的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: MyInstallerClass
//引入命名空間
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
// Set 'RunInstaller' attribute to true.
[RunInstaller(true)]
public class MyInstallerClass: Installer
{
public MyInstallerClass() :base()
{
// Attach the 'BeforeRollback' event.
this.BeforeRollback += new InstallEventHandler(MyInstaller_BeforeRollBack);
// Attach the 'AfterRollback' event.
this.AfterRollback += new InstallEventHandler(MyInstaller_AfterRollback);
}
// Event handler for 'BeforeRollback' event.
private void MyInstaller_BeforeRollBack(object sender, InstallEventArgs e)
{
Console.WriteLine("");
Console.WriteLine("BeforeRollback Event occurred.");
Console.WriteLine("");
}
// Event handler for 'AfterRollback' event.
private void MyInstaller_AfterRollback(object sender, InstallEventArgs e)
{
Console.WriteLine("");
Console.WriteLine("AfterRollback Event occurred.");
Console.WriteLine("");
}
// Override the 'Install' method.
public override void Install(IDictionary savedState)
{
base.Install(savedState);
// Explicitly throw an exception so that roll back is called.
throw new ArgumentException("Arg Exception");
}
// Override the 'Commit' method.
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
}
// Override the 'Rollback' method.
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
public static void Main()
{
Console.WriteLine("Usage : installutil.exe Installer_BeforeRollback.exe ");
}
}