首页 > 解决方案 > 在安装时安装 Visual C++ Redistributables 2005

问题描述

在我的 Windows 服务(Visual Studio 安装项目)的安装过程中,我仍然需要安装 Microsoft C++ 2005 Redistributables。我已经有在后台安装这些包的程序。该编程有效。现在我想在安装 Windows 服务时调用这个程序。但是我总是收到错误消息“正在安装另一个程序,请等待安装完成,然后再次尝试安装软件。” . 我已经尝试过 ProjectInstaller 类的所有方法(OnBeforeInstall、OnAfterInstall、Commit)——没有任何效果。但是在默认的先决条件中我不能选择这个包,因为它太旧了。

我该如何解决这个问题?

非常感谢!:)

标签: visual-studioinstallationsetup-projectredistributable

解决方案


安装时可以按照以下步骤进行Microsoft C++ 2005 Redistributables安装:

  1. 按照此文档为您的设置项目创建自定义操作。
  2. 在安装方法中添加这些代码
    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);

        Process myProcess = new Process();

        myProcess.StartInfo.FileName = @"{Your Directory}\vcredist_x86.EXE";

        myProcess.StartInfo.Arguments = "/Q";      //install automactically

        myProcess.StartInfo.CreateNoWindow = true;

        myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;

        myProcess.StartInfo.Verb = "runas";        //run exe as administrator(Important!)

        myProcess.Start();
    }

推荐阅读