Windows服务无法在某些本地系统上启动

时间:2012-09-30 07:02:38

标签: c# windows-services network-programming

我创建了一个Windows服务并将其安装在网络中的3台计算机上。

它在其中2个上工作正常,但它与第3个有问题。

我已经使用事件日志找出问题所在,但是它只是第一次重新启动系统时插入日志,而且我发现它只是在其构造函数中执行InitializeComponent()命令。 / p>

注意:我的服务应该在网络中插入所有帐户的登录和注销,并且需要在服务启动之前成功启动的3个依赖项。

修改 我已经按照本文创建了我的服务。以下代码只是服务的构造函数。

ComAdminCatalogClass comAdmin = new ComAdminCatalogClass();
ICatalogCollection subCollection;

//Service Constructor
Public Service1()
{
   try
   {
      EventLog.WriteEntry("Service1","1");
      InitializeComponent();
      EventLog.WriteEntry("Service1","2");

      subCollection = (ICatalogCollection)comAdmin.GetCollection("TransientSubscriptions");

      SubScribToEvent(subCollection, "Logon");
      SubScribToEvent(subCollection, "Logoff");
   }
   catch (Exception exp)
   {
      EventLog.WriteEntry("Service1",exp.Message);
   }
}

1 个答案:

答案 0 :(得分:0)

非常感谢@akton,我通过运行我的服务的exe来找到解决方案!!

太愚蠢了。第三个系统的事件查看器已满!我清除了所有日志,现在我的服务在所有三个系统中运行良好。

您可以按these steps清除所有活动