c# – 执行使用Visual Studio创建的* .msi文件时出错
我在visual studio 2013中使用c#创建了一个窗口服务.
Windows服务工作正常. 当我创建一个安装项目并在不同的计算机上运行.msi文件时,它给我一个错误 我做的步骤: 1.右键点击解决方案 – >其他项目类型 – > Visual Studio安装程序 – 安装项目 2.添加名称文件系统编辑器 – >选择应用程序文件夹 – >右键单击 – >添加 – >项目输出 – >弹出添加项目输出组 >选择自定义操作编辑器 – >安装 – >右CLick – >添加自定义操作 – >选择Application文件夹和Project输出. 对于卸载,重复相同的操作 >构建安装程序. 在该文件夹中创建.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 Installer项目. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |