- 积分
- 0
- 在线时间
- 9 小时
- 主题
- 2
- 注册时间
- 2018-8-27
- 帖子
- 4
- 最后登录
- 2018-9-3
- 帖子
- 4
- 软币
- 86
- 在线时间
- 9 小时
- 注册时间
- 2018-8-27
|
各位大神們好,
小弟最近在用Setup Project打包程式,稱呼為A。
其中因為專案需求,我必須在A的安裝過程中安裝一個InstallShield打包的安裝包B,
在this.AfterInstall及this.BeforeUninstall的部份分別加入了「安裝」及「反安裝」B的代碼,
不過卻無法順利執行,B產生的setup.log得到的ResultCode=-3,但原因不明…
懇請板上大神協助,這個問題困擾小弟好久,一直無法解決阿…謝謝!!
下述代碼中,InstallerHelper_AfterInstall及 InstallerHelper_BeforeUninstall內的代碼,分別放在新建立的C# console程式中,卻能正常運行,
且WaitforExit()也能順利卡住,而B安裝包也能順利執行,ResultCode=0。
代碼如下:
--
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...");
}
}
}
--
|
|