【问题标题】:When I try to start my Windows service, I get error number 1053当我尝试启动我的 Windows 服务时,我收到错误号 1053
【发布时间】:2012-12-06 12:29:30
【问题描述】:

当我使用命令提示符以如下所示的方式安装服务时,我正在尝试将参数传递给 Windows 服务

d:\mypath>installutil -i service.exe -参数

在 program.cs 文件中安装之前,我已经按照以下方式编写了

static void Main(string[] args)
        {
            **string path = args[0];**              
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
            { 
                **new VibrantEmail(path)** 
            };
            ServiceBase.Run(ServicesToRun);
        }

在 service.cs 页面中我已经写了这个

**public VibrantEmail(string path)**
        {
            **data = path**
            InitializeComponent();
        }

事情就像我使用 static void Main(string[] args) 在 program.cs 页面中,只有我收到此错误,编号 1053。 谁能帮帮我?

【问题讨论】:

    标签: asp.net windows-services


    【解决方案1】:

    您不能在安装步骤提供参数。 Installutil 只需要执行哪个安装程序组件的程序集。您必须使用Environment.GetCommandLineArgs 来检索代码中的参数,然后在不提供参数的情况下安装服务并根据this instructions 修改其执行路径。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-10
      • 2021-10-28
      • 2016-03-22
      • 2011-11-16
      • 1970-01-01
      • 1970-01-01
      • 2018-12-15
      • 2019-11-03
      相关资源
      最近更新 更多