6

ServiceInstallで宣言した引数を、サービスの起動時にサービスに渡す方法を知っている人はいますか?私のOnStart(string [] args)では常にnullのようです。

<ServiceInstall
              Id="ServiceInstaller"
              Type="ownProcess"
              Vital="yes"
              Name="MyService"
              DisplayName="MyService"
              Description="MyService Desc"
              Start="auto"
              Account="LocalSystem"
              ErrorControl="ignore"
              Interactive="yes"
              Arguments="MY ARGS HERE"
              >
              </ServiceInstall>
              <ServiceControl Id="ServiceControl" Start="install" Stop="both" Remove="uninstall" Name="MyService" Wait="yes" />
4

3 に答える 3

2

誰かがこれを進歩させますか?起動時にこの引数がサービスにヒットしていません。

          <ServiceInstall
            Id="ServiceInstaller"
            Type="ownProcess"
            Vital="yes"
            Name="Service"
            DisplayName="Service"
            Description="a service" 
            Arguments="-p stuff"
            Start="auto"
            Account="LocalSystem"
            ErrorControl="normal"
            Interactive="yes"/>

私のサービスは常に空の引数配列を取得します:

    partial class PrintMonitorService : ServiceBase
    {
    private readonly PrintMonitorServiceManager _serviceManager;

    public PrintMonitorService()
    {
        InitializeComponent();
        _serviceManager = new PrintMonitorServiceManager();
    }

    protected override void OnStart(string[] args)
    {
        _serviceManager.StartHosting(args);
    }

    protected override void OnStop()
    {
        _serviceManager.StopHosting();
    }
于 2012-09-21T07:11:11.473 に答える