gpt4 book ai didi

c# - 执行使用 Visual Studio 创建的 *.msi 文件时出错

转载 作者:行者123 更新时间:2023-11-30 12:57:21 33 4
gpt4 key购买 nike

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

当我创建安装项目并在不同的计算机上运行 .msi 文件时,出现错误

Error

我做的步骤:

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

2.添加名称后 File system Editor -> Select Application Folder -> 右键 -> Add -> Project output -> 弹出Add Project Output Group 项目:选择我的主要输出项目

File system editor

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

对卸载重复相同的操作

Custom Actions Editor

  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;
}
}

最佳答案

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

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

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

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

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

关于c# - 执行使用 Visual Studio 创建的 *.msi 文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34791959/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com