与安装项目安装指定Windows服务名称 [英] Specify Windows Service Name on install with Setup Project

查看:392
本文介绍了与安装项目安装指定Windows服务名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:为了支持Windows服务中可能有一台机器上的多个实例,使用安装项目来创建一个能够MSI:

Objective: In support of a Windows Service that may have multiple instances on a single machine, use a Setup Project to create an MSI capable of:


  1. 接收用户输入的服务名称

  2. 安装服务

  3. 从1序列化服务名称(以便正确的名称可在记录使用和卸载)

我最初的希望是设置服务名称中的App.config(然后经的ServiceInstaller的实例卸载期间检索。这似乎是幼稚的,因为它不是在安装过程中访问

My initial hope was to set Service Name in App.config (and then retrieve it during uninstall upon instantiation of the ServiceInstaller. This seems to have been naive, because it is not accessible during the install.

如果MyInstaller扩展安装程序,它可以调用base.Install();然而,我的尝试写的app.config(内MyInstaller.Install()和后base.Install())是inneffective。

If MyInstaller extends Installer, it can call base.Install(); however, my attempts to write to app.config (within MyInstaller.Install() and after base.Install()) are inneffective.

因此,尽管该服务可以用自定义服务安装名称,该名称是没有序列号和安装是最不高兴时卸载。

So while the service can be installed with a custom Service Name, that name is not serialized and the installer is most displeased upon uninstall.

应如何做?

推荐答案

您可以指定参数,安装人员的操作,所以收取的服务名称,并将其作为参数传递给动作。然后,在安装类,则可以覆盖安装()并通过访问它基地.Context.Parameters 。这就是你得到的价值。在获得该值,并用它,你把它放在 stateSaver 的IDictionary 参数,以便如果重写卸载()你可以找出什么价值上安装使用。

You can specify parameters to installer actions, so collect the service name, and pass it as a parameter to the action. Then, in the Installer class, you can override Install() and access it via base.Context.Parameters. That's how you get the value. Having obtained that value and used it, you put it in the stateSaver IDictionary parameter so that if you override Uninstall() you can find out what value was used on install.

这篇关于与安装项目安装指定Windows服务名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆