2011-02-24 48 views
0

我有一个NT服务,有一些性能计数器。当我使用installutil部署服务时,perf计数器和服务安装正常。当我使用我的msi进行部署时,使用ServiceInstall,该服务显示出来,但不会安装perf计数器。Perf计数器不使用服务安装使用ServiceInstall

我总是假设ServiceInstall在封面下运行installutil。是否有一些关键差异会阻止我安装perf计数器?

维克斯段

<ServiceInstall Id='ServiceInstall' ErrorControl='ignore' Type='ownProcess' DisplayName='Service' Description='service' Name='Service' Start='auto' Account='[SERVICEACCOUNT]' Password='[SERVICEACCOUNTPASSWORD]' /> 
<ServiceControl Id='Service' Remove='uninstall' Name='Service' Start='install' Stop='both' Wait='yes' /> 

性能计数器安装

[RunInstallerAttribute(true)] 
[RegistryPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)] 
[EnvironmentPermissionAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)] 
public sealed class CountersInstaller : Installer 
{ 
    public CountersInstaller() 
    { 
     Installers.AddRange(Counters.Instance.PerformanceCounterInstallers()); 
    } 
} 

回答

0

不,你的假设是不正确的。 ServiceInstall不会在安装性能计数器的情况下调用InstallUtil。使用InstallUtil通常被认为是不好的做法。

取而代之,请看PerformanceCategoryPerformanceCounter元素。当然,这需要一些编码来将您现在使用C#进行的操作转换为声明式XML表单。

+0

我很好奇。如果我的服务已经在使用.Net框架的一个版本,为什么调用InstallUtil会这么糟糕?它不会添加任何尚未存在的附加依赖关系,在这种情况下,它会简化部署。 – user467384 2011-02-24 21:33:38

+0

查看与WiX Toolset一起安装的dtf.chm文件。包含一篇名为“InstallUtil Notes”的文章。它给出了一些基本的想法。另外,您可能有兴趣查看此讨论:http://stackoverflow.com/questions/3241377/wix-service-installer-and-custom-install-events – 2011-02-25 06:39:54