相关疑难解决方法(0)

错误1053服务未响应启动或控制请求

我在C#中编写了一个Windows服务,它基本上每分钟检查我的数据库的订单,从这些订单生成PDF,并通过电子邮件发送.

逻辑在我的测试等中完美运行.

当我创建服务并使用安装项目安装它时,当我在服务mmc中启动服务时,我得到:

错误1053服务未及时响应启动或控制请求

我的OnStart方法如下所示:

protected override void OnStart(string[] args)
{
    //writeToWindowsEventLog("Service started", EventLogEntryType.Information);
    timer.Enabled = true;
}
Run Code Online (Sandbox Code Playgroud)

基本上,只需启用计时器......所以没有进程密集的呼叫.

我哪里错了?

我已经尝试将启动帐户设置为本地系统,网络服务等......没有任何作用!

编辑:

这是我的代码:(processPurchaseOrders是查询数据库并生成pdf的方法等...)

public partial class PurchaseOrderDispatcher : ServiceBase
{
    //this is the main timer of the service
    private System.Timers.Timer timer;

    public PurchaseOrderDispatcher()
    {
        InitializeComponent();
    }

    // The main entry point for the process
    static void Main()
    {
      #if (!DEBUG)
        ServiceBase[] ServicesToRun;
        ServicesToRun = new ServiceBase[] { new PurchaseOrderDispatcher() };
        ServiceBase.Run(ServicesToRun);
      #else //debug code
        PurchaseOrderDispatcher service = new PurchaseOrderDispatcher();
        service.processPurchaseOrders(); …
Run Code Online (Sandbox Code Playgroud)

c# windows error-handling windows-services

36
推荐指数
4
解决办法
7万
查看次数

标签 统计

c# ×1

error-handling ×1

windows ×1

windows-services ×1