Hello gods,
I have been using Setup Project to package the program recently, and it is called A. Due to project requirements, I had to install an installation package B packaged by InstallShield during the installation of A. In this. AfterInstall and this.BeforeUninstall parts add the code of "Install" and "Reverse Install" B respectively. However, it could not be executed smoothly, and the setup.log generated by B obtained ResultCode=-3, but the reason is unknown...
I beg the board god to help, this problem has troubled my little brother for a long time, and I have not been able to solve it... Thank you!!
In the following code, the code in the InstallerHelper_AfterInstall and InstallerHelper_BeforeUninstall is placed in the newly created C# console program, but it can run normally. And WaitforExit() can also get stuck smoothly, and the B installation package can also be executed smoothly, ResultCode=0.
The code is as follows: -- using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Configuration.Install; using System.Linq; using System.Threading.Tasks; using System.Configuration; using System.Windows; using System.IO; using System.Diagnostics; using System.Threading;
namespace FRWebService
{ [RunInstaller(true)] public partial class InstallerHelper : Installer { public InstallerHelper() {
InitializeComponent();
this. BeforeInstall += new InstallEventHandler(InstallerHelper_BeforeInstall); this. AfterInstall += new InstallEventHandler(InstallerHelper_AfterInstall);
this. BeforeUninstall += new InstallEventHandler(InstallerHelper_BeforeUninstall); this. AfterUninstall += new InstallEventHandler(InstallerHelper_AfterUninstall); }
private void InstallerHelper_BeforeUninstall(object sender, InstallEventArgs e) { try { String arg = "/s /uninst"; Process p = Process.Start("C:\\Program Files\\Test\\setup_io.exe", arg); p.WaitForInputIdle(); p.WaitForExit();
} catch (Exception ex) {
} }
private void InstallerHelper_BeforeInstall(object sender, InstallEventArgs e) {
}
private void InstallerHelper_Committing(object sender, InstallEventArgs e) {
}
private void InstallerHelper_Committed(object sender, InstallEventArgs e) {
}
private void InstallerHelper_AfterInstall(object sender, InstallEventArgs e) { try { String arg = "/s"; Process p = Process.Start("C:\\Program Files\\Test\\setup_io.exe", arg); p.WaitForInputIdle(); p.WaitForExit(); } catch (Exception ex) {
} }
private void InstallerHelper_AfterUninstall(object sender, InstallEventArgs e) {
}
//Code to perform at the time of installing application public override void Install(System.Collections.IDictionary stateSaver) { System.Diagnostics.Debugger.Launch(); base. Install(stateSaver); System.Windows.Forms.MessageBox.Show("Installing Application..."); }
public override void Uninstall(System.Collections.IDictionary stateSaver) { System.Diagnostics.Debugger.Launch(); base. Uninstall(stateSaver); System.Windows.Forms.MessageBox.Show("Uninstalling Application..."); }
}
} --
|