Windows 服务错误 1053

2024-04-14

我目前正在编写一个 Windows 服务,它连接到 crm 系统以拉下一个计划,然后运行各种数据源等。我已经一切正常,除了当我安装所有内容并尝试运行启动服务时,我收到以下错误:

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

这是我在 Service1.cs 中使用的代码;

namespace FeedManagementService
{
  public partial class Service1 : ServiceBase
  {
    private System.Timers.Timer timer;

public Service1()
{
  InitializeComponent();
}

protected override void OnStart(string[] args)
{
  // Instantiate the timer
  Thread t = new Thread(new ThreadStart(this.InitTimer));
  t.IsBackground = true;
  t.Start();
} // OnStart

protected override void OnStop()
{
  timer.Enabled = false;
} // OnStop

private void InitTimer()
{
  timer = new System.Timers.Timer();

  // Add the timer event
  timer.Elapsed += new ElapsedEventHandler(timerTick);

  // Set the interval
  double timeInSeconds = 6.0;
  timer.Interval = (timeInSeconds * 1000);
  timer.Enabled = true;
} // InitTimer()

private void timerTick(object sender, EventArgs e)
{
  // CRM connection stuffhere
} // timerTick
  }
}

然后在Service1.Designer.cs中添加以下内容

namespace FeedManagementService
{
  partial class Service1
  {
    /// <summary> 
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
      if (disposing && (components != null))
      {
        components.Dispose();
      }
      base.Dispose(disposing);
    }

    #region Component Designer generated code

    /// <summary> 
    /// Required method for Designer support - do not modify 
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      this.components = new System.ComponentModel.Container();
      this.ServiceName = "Feed Management Service";
      this.CanPauseAndContinue = true;
    } // InitializeComponent()

    #endregion
  }
}

最后是 ProjectInstaller.cs 中的以下内容

namespace FeedManagementService
{
  [RunInstaller(true)]
  public partial class ProjectInstaller : System.Configuration.Install.Installer
  {
    public ProjectInstaller()
    {
      ServiceProcessInstaller process = new ServiceProcessInstaller();

      process.Account = ServiceAccount.LocalSystem;

      ServiceInstaller serviceAdmin = new ServiceInstaller();

      serviceAdmin.StartType = ServiceStartMode.Manual;
      serviceAdmin.ServiceName = "Service1";
      serviceAdmin.DisplayName = "Feed Management Service";
      Installers.Add(process);
      Installers.Add(serviceAdmin);
    }
  }
}

经过大量调查并修复了一大堆与该问题无关的“问题”后,我发现我需要在服务的 Main() 方法中执行以下操作;

ServiceBase[] ServicesToRun;
  ServicesToRun = new ServiceBase[] 
        { 
            new Service1() 
        };
  ServiceBase.Run(ServicesToRun);

添加此内容后,现在一切似乎都工作正常,服务按预期启动。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Windows 服务错误 1053 的相关文章

随机推荐

  • Python 错误,“‘模块’对象没有属性‘lstrip’”

    Python 文档来自http docs python org library string html http docs python org library string html string lstrip s chars 返回删除了
  • 将特定 JSON 字段从 .responseText 提取到单个 Excel 单元格

    我正在尝试从 JSON 中检索特定字段 resolve 我不确定如何才能获得这一领域 我添加了 Msgbox Exists Fail 以查看代码是否能够读取单元格内的单词 resolve 但是我返回失败 有什么办法可以让我只获得现场解析吗
  • Doctrine - 如何在 postSave() 事件中获取 SQL INSERT 查询?

    我想获得当调用对象的 save 方法时 Doctrine 生成的确切 SQL INSERT 查询 最好 我想在模型的 postSave 事件中获取它并将其记录在 txt 文件中 例如 我想获取 记录以下 SQL 查询 INSERT INTO
  • 如何从 YouTube URL 获取 flv 文件路径

    我有一个 SWF 媒体播放器 播放 flv 视频 但我想让它播放 youtube 视频 所以我必须传递给播放器flv文件路径 该场景是一个我可以上传视频或输入网址的网站 我可以输入 YouTube 视频 URL 我正在使用 ASP NET
  • 如何加载图像以在 RCP 中查看?

    我正在开发一个RCP plugin project其中包括某些视图 第一个视图 员工详细信息 例如name address等等 有一个选项可以使用浏览按钮上传员工图像 第二个视图显示在第一个视图中输入的详细信息 除照片之外的所有详细信息都显
  • GitHub Actions - 如何在子目录中构建项目

    我正在使用 GitHub Actions 构建我的项目 但我的 Dart 项目位于存储库的子目录中 动作脚本找不到我的pubspec yaml并获取依赖项 如何指向我的 GitHub Action 在我的存储库的子目录中查找源代码 root
  • 如何使用 javascript 更改 div 内的 HTML 代码? [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我正在构建一个 HTML 网站 该网站的页面太多 所以我想要一个代码 以便我可以从我的网站编辑特定的 div 以便它将应用于我的网站中的所
  • WPF 和 MVVM:保存 ScrollViewer 位置并在重新加载时设置

    我有一个 StackPannel 的 ScrollViewer 用户希望保存 ScrollViewer 的位置 以便当应用程序重新加载其数据时 StackPannel 将显示他们之前查看的项目 它与选择哪些项目 如果有的话 无关 而只是 S
  • 姜戈。复杂的注释需要别名。这里的别名是什么?

    我试图通过以下查询获取模型的最大值和最小值 max min price MyModel objects annotate Min price Max price 但我收到错误 复杂的注释需要别名 我不确定别名在这里意味着什么 并且我认为文档
  • 测试助手类的正确位置在哪里? (phpunit/最佳实践)

    我想使用 PHPUnit 测试我的应用程序 所以我像往常一样有我的应用程序类和第二棵带有测试类的树 现在我需要进行一些测试 一种虚拟 模拟对象 我想知道应该将它们放在哪里 它是一个不同的用例 它应该放在公共 lib 文件夹中还是更喜欢什么
  • 如何使用 FirefoxProfile 在 FireFox Selenium Webdriver 中启用 Adob​​e Flash

    我需要一种自动化方法来在 Firefox Selenium Webdriver 中启用 Flash 而无需用户交互 我努力了 FirefoxProfile profile new FirefoxProfile As 0 is to disa
  • Azure 移动应用自定义身份验证

    我正在尝试使用来实现自定义身份验证LoginAsync string provider JObject token MobileServiceClient 的重载 我有一个像这样的自定义身份验证控制器 MobileAppController
  • 如何检查事件是否已存在一天 - fullcalendar

    如何在使用时检查事件是否已经存在一天renderEvent method 我发现可能在堆栈中回答dayClick with clientEvents 我不确定它如何用于renderEvent var diffDay 5 for var i
  • 如何选择博客模型中的最后一个和倒数第二个条目?

    我有一个模型 blog posts 其中有一个字段 published at 我想从该模型中选择最新的两个博客以显示在我的主页上 但不确定如何构建它 目前 我有一个解决方法 可以获取一部分数据 但当我表中没有任何内容时 它会不断失败 而不是
  • ARM架构中不同处理器模式下如何使用内核堆栈?

    据我了解 每个进程都有一个用户堆栈和内核堆栈 除此之外 ARM 架构中的每种模式都有一个堆栈 所以我想知道不同的堆栈和堆栈指针在 ARM 模式下如何工作 另外 何时会使用与进程关联的内核堆栈 何时会使用与进程关联的内核堆栈 当您进行系统调用
  • Python 中枚举的枚举?

    Python 中是否可以有枚举的枚举 例如 我想要 enumA enumB elementA elementB enumC elementC elementD 供我参考elementA as enumA enumB elementA 或参考
  • 设置 GLEW 窗口?

    我有 Visual Studio 2010 我想在其上设置 glew h 我执行了这一步 但仍然出现链接器错误 1 下载glew包 2 将 h文件复制到C Program Files x86 Microsoft SDKs Windows v
  • Parsley.js - 更改错误容器

    我想改变每个错误消息的位置 即在相应的位置显示错误消息 div class errorBlock div 通过使用文档代码 错误消息显示在元素 输入 之前 而不是按预期显示 有任何想法吗 根据文档 errors container func
  • Knex 连接 Heroku Postgres 时出现错误?

    我正在尝试将 Heroku Postgres 与 Knex 连接 它在本地运行良好 但是当我推 Heroku 时 并尝试注册一个帐户 我收到这个错误 code DEPTH ZERO SELF SIGNED CERT 但我推 Heroku 我
  • Windows 服务错误 1053

    我目前正在编写一个 Windows 服务 它连接到 crm 系统以拉下一个计划 然后运行各种数据源等 我已经一切正常 除了当我安装所有内容并尝试运行启动服务时 我收到以下错误 错误 1053 服务未响应启动或控制请求 及时时尚 这是我在 S