安装程序安装时安装Visual C++Redistributables 2005



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

我该如何解决这个问题?

非常感谢!:(

您可以按照以下步骤在安装时安装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();
}