我有一个 C# 应用程序。除此以外一切正常:
当我从添加/删除程序中卸载应用程序时,如果应用程序未关闭,它将在卸载后保持打开状态。
对于看不懂隐含问题的人...“我如何才能关闭应用程序?在卸载时?”。
如果您需要任何详细信息,请询问。
最佳答案
在您的安装程序项目中(我假设您已经使用 Visual Studio 中的安装程序项目生成了 MSI 安装程序),您应该包含一个继承自安装程序基类的类:
[RunInstaller(true)]
public class MyInstaller: Installer
{
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
//TODO: Code to kill the live instance(s)
}
// Other override methods here if necessary
}
此类的 Uninstall 方法将在用户卸载您的应用程序时执行。
在此方法中,您可以选择正在运行的进程列表并终止应用的所有事件实例。
关于c# - 运行 Windows 卸载程序时关闭应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5898443/