【问题标题】:Error in executing *.msi file created using Visual Studio执行使用 Visual Studio 创建的 *.msi 文件时出错
【发布时间】:2016-04-19 22:03:19
【问题描述】:

我在 Visual Studio 2013 中使用 c# 创建了一个窗口服务。 Windows 服务运行良好。

当我创建一个安装项目并在不同的计算机上运行 .msi 文件时,它给了我一个错误

我做的步骤:

1.右键解决方案->其他项目类型->Visual Studio安装程序-安装项目

2.添加名称后文件系统编辑器->选择应用程序文件夹->右键->添加->项目输出->添加项目输出组弹出 项目:选择我的主要输出项目

  1. 选择自定义动作编辑器 -> 安装 -> 右键单击​​ -> 添加自定义动作 -> 选择应用程序文件夹和项目输出。

对卸载重复相同的操作

  1. 构建安装程序。

.msi 和 setup.exe 文件在文件夹中创建。

我看到了 https://www.youtube.com/watch?v=cp2aFNtcZfk 教程来做到这一点。

谁能告诉我如何解决这个问题。

谢谢


编辑:我的项目中有 projectInstaller

namespace certify4byd_ver2._0
{
partial class ProjectInstaller
{

    private System.ComponentModel.IContainer components = null;

    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }


    private void InitializeComponent()
    {
        this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
        this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
        // 
        // serviceProcessInstaller1
        // 
        this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
        this.serviceProcessInstaller1.Password = null;
        this.serviceProcessInstaller1.Username = null;

        // 
        // serviceInstaller1
        // 
        this.serviceInstaller1.Description = "Quick Source specific development to allow ftp files to be send to ByDesign envir" +
"onment";
        this.serviceInstaller1.DisplayName = "Quick Source Certify4ByDesign";
        this.serviceInstaller1.ServiceName = "qs_certify4byd_v2.0";
        this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
        this.serviceInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_AfterInstall);
        // 
        // ProjectInstaller
        // 
        this.Installers.AddRange(new System.Configuration.Install.Installer[] {
        this.serviceProcessInstaller1,
        this.serviceInstaller1});

    }

    #endregion

    private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
    private System.ServiceProcess.ServiceInstaller serviceInstaller1;
    }
}

【问题讨论】:

标签: c# visual-studio visual-studio-2010 visual-studio-2012 visual-studio-2013


【解决方案1】:

从错误消息来看,您似乎已将应用程序的文件复制到目标计算机,仅此而已。如果您正在编写 Windows 服务,则必须采取其他步骤来获取 MSI 包以将其安装为服务。

您的项目是否在某处有 ServiceInstaller 类?这就是 .NET 希望您安装服务的方式。

至少根据我的经验,Visual Studio 安装程序项目可能不是最好的方法。查看Debuggable Installable Service,它是 Visual Studio 的一个扩展,它允许您创建自安装的 Windows 服务(带有命令行参数),这些服务也可以开箱即用地进行控制台调试。在编写服务时,它对我来说是一个救命稻草,因为您不会乱用ServiceInstaller,一切都为您完成。

我的另一个建议是,除了使用 Debuggable Installable Service 之外,还请查看 WiX Toolset。它需要安装在您计划开发产品的任何地方(如果您在源代码控制下开发会有点痛苦),但它还允许您安装服务并让您更精细地控制应用程序的运行方式安装。

我不推荐 Visual Studio 安装程序项目。

【讨论】:

  • 我的项目中有服务安装程序。请参阅已编辑区域。感谢您提供其他工具的建议。我过去曾在 VS 安装程序项目中使用过。我想我错过了一些我无法验证的东西。
猜你喜欢
  • 1970-01-01
  • 2015-03-30
  • 1970-01-01
  • 1970-01-01
  • 2016-12-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多